comparison sat/core/log_config.py @ 3056:49c7bc3afb2b

core (log): removed Android hack: this hack is not needed anymore with Python 3 port and was actually causing a crash.
author Goffi <goffi@goffi.org>
date Wed, 16 Oct 2019 08:39:35 +0200
parents ab2696e34d29
children 9d0df638c8b4
comparison
equal deleted inserted replaced
3055:82eee2c383d9 3056:49c7bc3afb2b
331 self.level = level 331 self.level = level
332 332
333 def configureFormat(self, fmt): 333 def configureFormat(self, fmt):
334 super(ConfigureStandard, self).configureFormat(fmt) 334 super(ConfigureStandard, self).configureFormat(fmt)
335 import logging 335 import logging
336 import sys
337 336
338 class SatFormatter(logging.Formatter): 337 class SatFormatter(logging.Formatter):
339 """Formatter which manage SàT specificities""" 338 """Formatter which manage SàT specificities"""
340 _format = fmt 339 _format = fmt
341 _with_profile = "%(profile)s" in fmt 340 _with_profile = "%(profile)s" in fmt
357 else: 356 else:
358 record.color_start = record.color_end = "" 357 record.color_start = record.color_end = ""
359 s = super(SatFormatter, self).format(record) 358 s = super(SatFormatter, self).format(record)
360 if do_color: 359 if do_color:
361 s = ConfigureStandard.ansiColors(record.levelname, s) 360 s = ConfigureStandard.ansiColors(record.levelname, s)
362 if sys.platform == "android": 361 return s
363 # FIXME: dirty hack to workaround android encoding issue on log
364 # need to be fixed properly
365 return s.encode("ascii", "ignore")
366 else:
367 return s
368 362
369 self.formatterClass = SatFormatter 363 self.formatterClass = SatFormatter
370 364
371 def configureOutput(self, output): 365 def configureOutput(self, output):
372 self.manageOutputs(output) 366 self.manageOutputs(output)