Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/output.py
diff options
context:
space:
mode:
authorAnton Hvornum <anton.feeds+github@gmail.com>2020-11-04 23:45:45 +0000
committerAnton Hvornum <anton.feeds+github@gmail.com>2020-11-04 23:45:45 +0000
commitab69cb752595de1a020ff5e809f6166db9dbf00d (patch)
tree449c3618dda314c7ae00fa0c22a312e24b2563c5 /archinstall/lib/output.py
parentd85c485b3a33519cba914d0f88399eabc385bf88 (diff)
Cleaned up some logic. How the LOG_LEVEL is fetched from the storage.
Diffstat (limited to 'archinstall/lib/output.py')
-rw-r--r--archinstall/lib/output.py24
1 files changed, 8 insertions, 16 deletions
diff --git a/archinstall/lib/output.py b/archinstall/lib/output.py
index bba02cd7..215ebe45 100644
--- a/archinstall/lib/output.py
+++ b/archinstall/lib/output.py
@@ -2,6 +2,7 @@ import abc
import os
import sys
import logging
+from .storage import storage
class LOG_LEVELS:
Critical = 0b001
@@ -72,25 +73,16 @@ def stylize_output(text :str, *opts, **kwargs):
text = '%s\x1b[%sm' % (text or '', RESET)
return '%s%s' % (('\x1b[%sm' % ';'.join(code_list)), text or '')
-GLOB_IMP_ERR_NOTIFIED = False
def log(*args, **kwargs):
if 'level' in kwargs:
- try:
- import archinstall
- if 'LOG_LEVEL' not in archinstall.storage:
- archinstall.storage['LOG_LEVEL'] = LOG_LEVELS.Info
-
- if kwargs['level'] >= archinstall.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
- except ModuleNotFoundError:
- global GLOB_IMP_ERR_NOTIFIED
-
- if GLOB_IMP_ERR_NOTIFIED is False:
- print('[Error] Archinstall not found in global import path. Can not determain log level for log messages.')
+ if 'LOG_LEVEL' not in storage:
+ storage['LOG_LEVEL'] = LOG_LEVELS.Info
- GLOB_IMP_ERR_NOTIFIED = True
+ 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])