Include offlineimap and pid in non interactive logs

This patch includes the "offlineimap" string and the proccess id
in the output for non interactive logs and syslog logs.

Now, the output is something like this (syslog):

Oct 11 21:55:10 yangon offlineimap[635798]: Syncing foo: IMAP -> Maildir
Oct 11 21:55:10 yangon offlineimap[635798]: Syncing foo bar: IMAP -> Maildir
Oct 11 21:55:10 yangon offlineimap[635798]: Syncing INBOX: IMAP -> Maildir
Oct 11 21:55:10 yangon offlineimap[635798]: Syncing bar: IMAP -> Maildir
Oct 11 21:55:10 yangon offlineimap[635798]: Syncing Trash: IMAP -> Maildir

Closes #88
This commit is contained in:
Rodolfo García Peñas (kix) 2021-10-11 22:03:33 +02:00
parent 2ce05bc98a
commit f8cfe98d9c
2 changed files with 2 additions and 2 deletions

View File

@ -45,7 +45,7 @@ class Syslog(UIBase):
# create syslog handler
ch = logging.handlers.SysLogHandler('/dev/log')
# create formatter and add it to the handlers
self.formatter = logging.Formatter("%(message)s")
self.formatter = logging.Formatter("offlineimap[%(process)d]: %(message)s")
ch.setFormatter(self.formatter)
# add the handlers to the logger
self.logger.addHandler(ch)

View File

@ -99,7 +99,7 @@ class UIBase:
# create syslog handler
ch = logging.handlers.SysLogHandler('/dev/log')
# create formatter and add it to the handlers
self.formatter = logging.Formatter("%(message)s")
self.formatter = logging.Formatter("offlineimap[%(process)d]: %(message)s")
ch.setFormatter(self.formatter)
# add the handlers to the logger
self.logger.addHandler(ch)