Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall
diff options
context:
space:
mode:
authorAnton Hvornum <anton.feeds+github@gmail.com>2020-11-04 23:53:39 +0000
committerAnton Hvornum <anton.feeds+github@gmail.com>2020-11-04 23:53:39 +0000
commitf594e6638a4fe772b5126e483887cbcc8704d3c0 (patch)
tree382efcc98f83c6b3645f071df8ca4027916f5264 /archinstall
parentab69cb752595de1a020ff5e809f6166db9dbf00d (diff)
Fixed level issues on log output. Also tweaked it so that all log rows come to the log file, but not nessecarily the interactive screen (tty/journald). Also tweaked certain log messages to be printed vs not printed.
Diffstat (limited to 'archinstall')
-rw-r--r--archinstall/lib/general.py2
-rw-r--r--archinstall/lib/output.py24
2 files changed, 15 insertions, 11 deletions
diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py
index 025dcc8b..6abef205 100644
--- a/archinstall/lib/general.py
+++ b/archinstall/lib/general.py
@@ -245,7 +245,7 @@ class sys_command():#Thread):
self.exit_code = 0
if self.exit_code != 0 and not self.kwargs['suppress_errors']:
- self.log(f"'{self.raw_cmd}' did not exit gracefully, exit code {self.exit_code}.", level=LOG_LEVELS.Debug)
+ self.log(f"'{self.raw_cmd}' did not exit gracefully, exit code {self.exit_code}.", level=LOG_LEVELS.Error)
self.log(self.trace_log.decode('UTF-8'), level=LOG_LEVELS.Debug)
raise SysCallError(f"'{self.raw_cmd}' did not exit gracefully, exit code {self.exit_code}.\n{self.trace_log.decode('UTF-8')}")
diff --git a/archinstall/lib/output.py b/archinstall/lib/output.py
index 215ebe45..8896c2a1 100644
--- a/archinstall/lib/output.py
+++ b/archinstall/lib/output.py
@@ -74,16 +74,6 @@ def stylize_output(text :str, *opts, **kwargs):
return '%s%s' % (('\x1b[%sm' % ';'.join(code_list)), text or '')
def log(*args, **kwargs):
- if 'level' in kwargs:
- if 'LOG_LEVEL' not in storage:
- storage['LOG_LEVEL'] = LOG_LEVELS.Info
-
- if kwargs['level'] >= storage['LOG_LEVEL']:
- print(f"Level {kwargs['level']} is higher than storage log level {storage['LOG_LEVEL']}.")
- # Level on log message was Debug, but output level is set to Info.
- # In that case, we'll drop it.
- return None
-
string = orig_string = ' '.join([str(x) for x in args])
if supports_color():
@@ -91,6 +81,7 @@ def log(*args, **kwargs):
string = stylize_output(string, **kwargs)
# Log to a file output unless specifically told to suppress this feature.
+ # (level has no effect on the log file, everything will be written there)
if 'file' in kwargs and not 'suppress' in kwargs and kwargs['suppress']:
if type(kwargs['file']) is str:
with open(kwargs['file'], 'a') as log_file:
@@ -99,10 +90,23 @@ def log(*args, **kwargs):
kwargs['file'].write(f"{orig_string}\n")
# If we assigned a level, try to log it to systemd's journald.
+ # Unless the level is higher than we've decided to output interactively.
+ # (Remember, log files still get *ALL* the output despite level restrictions)
if 'level' in kwargs:
+ if 'LOG_LEVEL' not in storage:
+ storage['LOG_LEVEL'] = LOG_LEVELS.Info
+
+ if kwargs['level'] > storage['LOG_LEVEL']:
+ print(f"Level {kwargs['level']} is higher than storage log level {storage['LOG_LEVEL']}.")
+ # Level on log message was Debug, but output level is set to Info.
+ # In that case, we'll drop it.
+ return None
+
try:
journald.log(string, level=kwargs['level'])
except ModuleNotFoundError:
pass # Ignore writing to journald
+ # Finally, print the log unless we skipped it based on level.
+ # And we print the string which may or may not contain color formatting.
print(string) \ No newline at end of file