I have currently several formats depending on the "level" (info, error,..)
Trying to do this within self.plugin_file_handler.setFormatter(logformat), it seems that there is only one format for file and std indigo log at a time
A switch between formats for eg error and info would require
- Code: Select all
logformatERROR = logging.Formatter('%(asctime)s.%(msecs)03d\t%(levelname)-12s\t%(name)s.%(funcName)-25s %(msg)s', datefmt='%Y-%m-%d %H:%M:%S')
logformatINFO = logging.Formatter('%(asctime)s %(msg)s', datefmt='%H:%M:%S')
### then in the code
self.plugin_file_handler.setFormatter(logformatERROR)
self.mylogger.ERROR("this is an error")
....
....
self.plugin_file_handler.setFormatter(logformatINFO)
self.mylogger.INFO("this is an info printout")
is there anyway to have several format definitions action for ONE log file, without always having to activate the ERROR/ INFO format when needed?
right now I am doing this all in one line:
if self.myLog.decide( "socket"): self.myLog.Print(text=" this is the text", mType="this goes in front of the line",errorType="small/big"), showDate=True,... )
and myLog does all the "work"
thanks
Karl