diff options
| author | Julia Kreger <juliaashleykreger@gmail.com> | 2021-03-30 07:58:34 -0700 |
|---|---|---|
| committer | Julia Kreger <juliaashleykreger@gmail.com> | 2021-04-01 11:16:20 -0700 |
| commit | df418984f037856813b6bc5e495ef602a6737ee3 (patch) | |
| tree | daa6b60b295567538e3a99ecb4440ebf531c4170 /ironic_python_agent/utils.py | |
| parent | 49d123dd6e32ea1455da1a2f11d6e624d435c308 (diff) | |
| download | ironic-python-agent-df418984f037856813b6bc5e495ef602a6737ee3.tar.gz | |
Capture the early logging
_early_log prints to stdout, which is fine in some cases,
however in other cases it gets lost in the shuffle of process
launch by things like systemd.
Lets try to save everything, and re-log it so it is easy to
debug early issues.
Change-Id: I334a9073d17cccec4c669fae82edc3e388debc5c
Diffstat (limited to 'ironic_python_agent/utils.py')
| -rw-r--r-- | ironic_python_agent/utils.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/ironic_python_agent/utils.py b/ironic_python_agent/utils.py index f045a4fe..dd68a526 100644 --- a/ironic_python_agent/utils.py +++ b/ironic_python_agent/utils.py @@ -78,6 +78,8 @@ DEVICE_EXTRACTOR = re.compile(r'^(?:(.*\d)p|(.*\D))(?:\d+)$') PARTED_TABLE_TYPE_REGEX = re.compile(r'^.*partition\s+table\s*:\s*(gpt|msdos)', re.IGNORECASE) +_EARLY_LOG_BUFFER = [] + def execute(*cmd, **kwargs): """Convenience wrapper around ironic_lib's execute() method. @@ -187,7 +189,16 @@ def _get_vmedia_params(): def _early_log(msg, *args): """Log via printing (before oslo.log is configured).""" - print('ironic-python-agent:', msg % args, file=sys.stderr) + log_entry = msg % args + _EARLY_LOG_BUFFER.append(log_entry) + print('ironic-python-agent:', log_entry, file=sys.stderr) + + +def log_early_log_to_logger(): + """Logs early logging events to the configured logger.""" + + for entry in _EARLY_LOG_BUFFER: + LOG.info("Early logging: %s", entry) def _copy_config_from(path): |
