diff options
author | Mary Ruthven <mruthven@google.com> | 2018-11-29 19:20:26 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-12-03 16:41:08 -0800 |
commit | 360b6e1a16bed7a5c4b3d83e50a80ebc8aaf69d4 (patch) | |
tree | 2362c7630953b4406447d70c37c5764b9798dfcd | |
parent | 5d6a41affa62970207936ded64023440f82abb65 (diff) | |
download | chrome-ec-360b6e1a16bed7a5c4b3d83e50a80ebc8aaf69d4.tar.gz |
ec3po: use a copy of the logger object
Use a copy of the console and interpreter logger objects, so modifying
the log level for one console does not affect the others.
With this change you can enable the debug log level on the cr50 console
without enabling debug for the ec console. The ec console prints a lot
more messages than cr50, so it can be difficult to debug cr50 console
issues if both consoles are set to debug.
BUG=none
BRANCH=none
TEST=verify setting cr50 loglevel does not affect the ec loglevel.
Change-Id: I529bf686443bf9df004e209e880f811608eef6a8
Signed-off-by: Mary Ruthven <mruthven@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1355967
Commit-Ready: Mary Ruthven <mruthven@chromium.org>
Tested-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org>
-rwxr-xr-x | util/ec3po/console.py | 5 | ||||
-rw-r--r-- | util/ec3po/interpreter.py | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/util/ec3po/console.py b/util/ec3po/console.py index 66ed9ea53b..4244061b5c 100755 --- a/util/ec3po/console.py +++ b/util/ec3po/console.py @@ -13,6 +13,7 @@ session-persistent command history. from __future__ import print_function import argparse +import copy import ctypes import binascii # pylint: disable=cros-logging-import @@ -148,7 +149,9 @@ class Console(object): unidirectional pipe attached to the intepreter. EC debug messages use this pipe. """ - logger = logging.getLogger('EC3PO.Console') + # Copy the logger, so modifying one ec3po logger level will not modify the + # loglevel for every ec3po console. + logger = copy.copy(logging.getLogger('EC3PO.Console')) self.logger = interpreter.LoggerAdapter(logger, {'pty': user_pty}) self.master_pty = master_pty self.user_pty = user_pty diff --git a/util/ec3po/interpreter.py b/util/ec3po/interpreter.py index 86272f6646..305dc81812 100644 --- a/util/ec3po/interpreter.py +++ b/util/ec3po/interpreter.py @@ -16,6 +16,7 @@ from __future__ import print_function import binascii # pylint: disable=cros-logging-import +import copy import logging import os import Queue @@ -91,7 +92,9 @@ class Interpreter(object): log_level: An optional integer representing the numeric value of the log level. By default, the log level will be logging.INFO (20). """ - logger = logging.getLogger('EC3PO.Interpreter') + # Copy the logger, so modifying one ec3po logger level will not modify the + # loglevel for every ec3po interpreter. + logger = copy.copy(logging.getLogger('EC3PO.Interpreter')) self.logger = LoggerAdapter(logger, {'pty': ec_uart_pty}) self.ec_uart_pty = open(ec_uart_pty, 'a+') self.ec_uart_pty_name = ec_uart_pty |