robots.helpers package¶
robots.helpers.ansistrm module¶
An ANSI-based colored console log handler, based on https://gist.github.com/758430, and with a few special features to make sure it works well in pyRobots’ concurrent environment.
-
class
robots.helpers.ansistrm.
ConcurrentColorizingStreamHandler
(scheme=None)[source]¶ Bases:
logging.StreamHandler
A log handler that:
- (tries to) guarantee strong thread-safety: the threads generating log
message can be interrupted at any time without causing dead-locks (which
is not the case with a regular
StreamHandler
: the calling thread may be interrupted while it owns a lock on stdout) - propagate pyRobots signals (ActionCancelled, ActionPaused)
- colors the output (nice!)
-
bright_scheme
= {40: (None, 'red', False, False), 10: (None, 'blue', False, False), 20: (None, 'white', False, False), 50: ('red', 'white', True, False), 30: (None, 'yellow', False, False)}¶
-
color_map
= {'blue': 4, 'black': 0, 'yellow': 3, 'cyan': 6, 'green': 2, 'magenta': 5, 'white': 7, 'red': 1}¶
-
csi
= '\x1b['¶
-
dark_scheme
= {40: (None, 'red', False, False), 10: (None, 'blue', False, False), 20: (None, 'black', False, False), 50: ('red', 'black', True, False), 30: (None, 'yellow', False, False)}¶
-
handle
(record)[source]¶ Override the default handle method to remove locking, because Python logging, while thread-safe according to the doc, does not play well with us raising signals (ie exception) at anytime (including while the logging system is locking the output stream).
-
is_tty
¶
-
mono_scheme
= {40: (None, None, False, False), 10: (None, None, False, False), 20: (None, None, False, False), 50: (None, None, False, False), 30: (None, None, False, False)}¶
-
reset
= '\x1b[0m'¶
-
xmas_scheme
= {40: ('red', 'yellow', False, True), 10: ('red', 'yellow', False, True), 20: ('red', 'white', False, True), 50: ('red', 'white', False, True), 30: ('red', 'yellow', False, True)}¶
- (tries to) guarantee strong thread-safety: the threads generating log
message can be interrupted at any time without causing dead-locks (which
is not the case with a regular