##// END OF EJS Templates
Application.log_format is a configurable
MinRK -
Show More
@@ -133,6 +133,9 class Application(SingletonConfigurable):
133 133 self.log_level = new
134 134 self.log.setLevel(new)
135 135
136 log_format = Unicode("[%(name)s] %(message)s", config=True,
137 help="The Logging format template",
138 )
136 139 log = Instance(logging.Logger)
137 140 def _log_default(self):
138 141 """Start logging for this application.
@@ -149,7 +152,7 class Application(SingletonConfigurable):
149 152 _log_handler = logging.StreamHandler(open(os.devnull, 'w'))
150 153 else:
151 154 _log_handler = logging.StreamHandler()
152 _log_formatter = logging.Formatter("[%(name)s] %(message)s")
155 _log_formatter = logging.Formatter(self.log_format)
153 156 _log_handler.setFormatter(_log_formatter)
154 157 log.addHandler(_log_handler)
155 158 return log
@@ -102,6 +102,10 class BaseParallelApplication(BaseIPythonApplication):
102 102 def _log_level_default(self):
103 103 # temporarily override default_log_level to INFO
104 104 return logging.INFO
105
106 def _log_format_default(self):
107 """override default log format to include time"""
108 return u"%(asctime)s.%(msecs).03d [%(name)s] %(message)s"
105 109
106 110 work_dir = Unicode(os.getcwdu(), config=True,
107 111 help='Set the working dir for the process.'
@@ -182,7 +186,7 class BaseParallelApplication(BaseIPythonApplication):
182 186 else:
183 187 self._log_handler = self.log.handlers[0]
184 188 # Add timestamps to log format:
185 self._log_formatter = logging.Formatter("%(asctime)s.%(msecs).03d [%(name)s] %(message)s",
189 self._log_formatter = logging.Formatter(self.log_format,
186 190 datefmt="%Y-%m-%d %H:%M:%S")
187 191 self._log_handler.setFormatter(self._log_formatter)
188 192 # do not propagate log messages to root logger
General Comments 0
You need to be logged in to leave comments. Login now