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