Conversation
|
Can one of the admins verify this patch? |
- use logging.Formatter.converter = time.gmtime for both the file config and fallback config to have the same (UTC) time, in both cases - unify log levels
Thank you for contributing to the Leapp project!Please note that every PR needs to comply with the Leapp Guidelines, pass tests and linter checks before it can be merged. If you want to re-run tests or request review, you can use following commands as a comment:
|
| Run a command and return its result as a dict. | ||
|
|
||
| The execution of the program and it's results are captured by the audit. | ||
| The execution of the command and its result is captured by the audit. The CalledProcessError is raised when |
There was a problem hiding this comment.
there is a special docstring syntax for the definition of what being raised:
@@ -151,8 +151,7 @@ def run(args, split=False, callback_raw=_console_logging_handler, callback_lineb
"""
Run a command and return its result as a dict.
- The execution of the command and its result is captured by the audit. The CalledProcessError is raised when
- the command exits with non-zero code.
+ The execution of the command and its result is captured by the audit.
:param args: Command to execute
:type args: list or tuple
@@ -168,6 +167,8 @@ def run(args, split=False, callback_raw=_console_logging_handler, callback_lineb
:type stdin: int, str
:return: {'stdout' : stdout, 'stderr': stderr, 'signal': signal, 'exit_code': exit_code, 'pid': pid}
:rtype: dict
+ :raises:
+ CalledProcessError: if the command exits with non-zero status
"""
if not args:
message = 'Command to call is missing.'| datefmt=log_date_format, | ||
| stream=sys.stderr, | ||
| ) | ||
| stderr_handler = logging.StreamHandler(sys.stderr) |
There was a problem hiding this comment.
No need to put sys.stderr, it is by default
| global _logger | ||
| if not _logger: | ||
| """ | ||
| Configure loggers as per the description below. |
There was a problem hiding this comment.
Should be on the same line with """ (https://www.python.org/dev/peps/pep-0257/#multi-line-docstrings)
| log_format = '%(asctime)s.%(msecs)-3d %(levelname)-8s PID: %(process)d %(name)s: %(message)s' | ||
| log_date_format = '%Y-%m-%d %H:%M:%S' | ||
| path = os.getenv('LEAPP_LOGGER_CONFIG', '/etc/leapp/logger.conf') | ||
| logging.Formatter.converter = time.gmtime |
There was a problem hiding this comment.
Please don't do this. This is a global state of all loggers. What about the one from the cookbook? (https://docs.python.org/3/howto/logging-cookbook.html#formatting-times-using-utc-gmt-via-configuration)
this could be solved something similar to:
diff --git a/etc/leapp/logger.conf b/etc/leapp/logger.conf
index ee1cf91..66102c4 100644
--- a/etc/leapp/logger.conf
+++ b/etc/leapp/logger.conf
@@ -10,7 +10,7 @@ keys=leapp_audit,stream
[formatter_leapp]
format=%(asctime)s.%(msecs)-3d %(levelname)-8s PID: %(process)d %(name)s: %(message)s
datefmt=%Y-%m-%d %H:%M:%S
-class=logging.Formatter
+class=leapp.logger.UTCFormatter
[logger_urllib3]
level=WARN| if not _leapp_logger: | ||
| _leapp_logger = logging.getLogger('leapp') | ||
|
|
||
| log_format = '%(asctime)s.%(msecs)-3d %(levelname)-8s PID: %(process)d %(name)s: %(message)s' |
There was a problem hiding this comment.
I think fo ruser would be convininent to see that this time is UTC time
| log_format = '%(asctime)s.%(msecs)-3d %(levelname)-8s PID: %(process)d %(name)s: %(message)s' | |
| log_format = '%(asctime)s.%(msecs)-3d UTC %(levelname)-8s PID: %(process)d %(name)s: %(message)s' |
In case of docstring, quotes should be used always, officialy. Replace apostrophes by quotes in case of docstrings.
|
@oamg/developers Do we still want this? I'd rather close and reopen on demand. |
Uh oh!
There was an error while loading. Please reload this page.