Add custom logging formatter
darcs-hash:20080904193953-86b55-bfb3ba3907f8aad6cd70413f9d38584d862cc9f6.gz
This commit is contained in:
@@ -32,6 +32,8 @@ from jcl.jabber.component import JCLComponent
|
|||||||
import jcl.model as model
|
import jcl.model as model
|
||||||
from jcl.model.account import Account, PresenceAccount, User, LegacyJID
|
from jcl.model.account import Account, PresenceAccount, User, LegacyJID
|
||||||
|
|
||||||
|
LOG_FORMATTER = logging.Formatter(fmt="[%(levelname)s] %(asctime)s (%(pathname)s:%(lineno)d): %(message)s")
|
||||||
|
|
||||||
class JCLRunner(object):
|
class JCLRunner(object):
|
||||||
|
|
||||||
def __init__(self, component_name, component_version):
|
def __init__(self, component_name, component_version):
|
||||||
@@ -169,9 +171,13 @@ class JCLRunner(object):
|
|||||||
self.__apply_configfile(commandline_args, cleanopts)
|
self.__apply_configfile(commandline_args, cleanopts)
|
||||||
self.__apply_commandline_args(commandline_args, cleanopts)
|
self.__apply_commandline_args(commandline_args, cleanopts)
|
||||||
if self.log_stdout:
|
if self.log_stdout:
|
||||||
self.logger.addHandler(logging.StreamHandler())
|
handler = logging.StreamHandler()
|
||||||
|
handler.setFormatter(LOG_FORMATTER)
|
||||||
|
logging.Logger.root.addHandler(handler)
|
||||||
if self.log_file is not None:
|
if self.log_file is not None:
|
||||||
self.logger.addHandler(logging.FileHandler(self.log_file))
|
handler = logging.FileHandler(self.log_file)
|
||||||
|
handler.setFormatter(LOG_FORMATTER)
|
||||||
|
logging.Logger.root.addHandler(handler)
|
||||||
|
|
||||||
def _get_help(self):
|
def _get_help(self):
|
||||||
help = self.component_name + " v" + self.component_version + " help:\n"
|
help = self.component_name + " v" + self.component_version + " help:\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user