mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-python
synced 2026-01-15 09:53:32 +01:00
log.py: Improve console color implementation
o Remove unnecessary function prio_colors() o Don't output color codes on non-TTY output Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
f810a7cdc1
commit
26d322023a
1 changed files with 5 additions and 6 deletions
|
|
@ -116,7 +116,7 @@ def slog(prio, *args, **kwargs): # export
|
|||
msg += misc.pad(name, _file_name_len) + '[' + misc.pad(str(line), 4, True) + ']'
|
||||
|
||||
if f_color in _flags:
|
||||
color_on, color_off = _prio_colors[prio]
|
||||
color_on, color_off = console_color_chars(prio)
|
||||
|
||||
msg += _log_prefix
|
||||
|
||||
|
|
@ -174,8 +174,10 @@ def parse_log_prio_str(prio): # export
|
|||
return map_prio_str_to_val[prio]
|
||||
raise Exception("Unknown priority string \"", prio, "\"")
|
||||
|
||||
def prio_colors(prio): # export
|
||||
return _prio_colors(prio)
|
||||
def console_color_chars(prio): # export
|
||||
if not sys.stdout.isatty():
|
||||
return [ '', '' ]
|
||||
return _prio_colors[prio]
|
||||
|
||||
def set_level(level_): # export
|
||||
global _level
|
||||
|
|
@ -222,6 +224,3 @@ def set_filename_length(l): # export
|
|||
if l:
|
||||
_file_name_len = l
|
||||
return r
|
||||
|
||||
def console_color_chars(prio): # export
|
||||
return _prio_colors[prio]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue