Mercurial > libervia-backend
comparison sat/core/log_config.py @ 2732:e55f871fa9db
core (log): fixed double call to ansiColors
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 27 Dec 2018 11:40:04 +0100 |
parents | 56f94936df1e |
children | 003b8b4b56a7 |
comparison
equal
deleted
inserted
replaced
2731:a58e380c1c37 | 2732:e55f871fa9db |
---|---|
54 | 54 |
55 try: | 55 try: |
56 isatty = sys.stdout.isatty() | 56 isatty = sys.stdout.isatty() |
57 except AttributeError: | 57 except AttributeError: |
58 isatty = False | 58 isatty = False |
59 if ( | 59 # FIXME: isatty should be tested on each handler, not globaly |
60 force_colors or isatty | 60 if (force_colors or isatty): |
61 ): # FIXME: isatty should be tested on each handler, not globaly | |
62 # we need colors | 61 # we need colors |
63 log.Logger.post_treat = lambda logger, level, message: self.ansiColors( | 62 log.Logger.post_treat = lambda logger, level, message: self.ansiColors( |
64 level, message | 63 level, message |
65 ) | 64 ) |
66 elif force_colors: | 65 elif force_colors: |
121 # we add colors if possible | 120 # we add colors if possible |
122 if ( | 121 if ( |
123 can_colors and self.LOGGER_CLASS.colors | 122 can_colors and self.LOGGER_CLASS.colors |
124 ) or self.LOGGER_CLASS.force_colors: | 123 ) or self.LOGGER_CLASS.force_colors: |
125 message = event.get("message", tuple()) | 124 message = event.get("message", tuple()) |
126 level = event.get("level", C.LOG_LVL_INFO) | |
127 if message: | 125 if message: |
128 event["message"] = ( | 126 event["message"] = ("".join(message),) # must be a tuple |
129 self.ansiColors(level, "".join(message)), | |
130 ) # must be a tuple | |
131 observer(event) # we can now call the original observer | 127 observer(event) # we can now call the original observer |
132 | 128 |
133 return observer_hook | 129 return observer_hook |
134 | 130 |
135 def changeFileLogObserver(self, observer): | 131 def changeFileLogObserver(self, observer): |