Simpligied installer.log() to wrap output.log() with it's changes.
This commit is contained in:
parent
f31d5e34cd
commit
828a09b9c8
|
|
@ -41,7 +41,6 @@ class Installer():
|
|||
self.init_time = time.strftime('%Y-%m-%d_%H-%M-%S')
|
||||
self.milliseconds = int(str(time.time()).split('.')[1])
|
||||
|
||||
|
||||
if logdir:
|
||||
storage['LOG_PATH'] = logdir
|
||||
if logfile:
|
||||
|
|
@ -60,16 +59,10 @@ class Installer():
|
|||
self.boot_partition = boot_partition
|
||||
|
||||
def log(self, *args, level=LOG_LEVELS.Debug, **kwargs):
|
||||
if not file:
|
||||
if 'logfile' not in storage:
|
||||
log_root = os.path.join(os.path.expanduser('~/'), '.cache/archinstall')
|
||||
if not os.path.isdir(log_root):
|
||||
os.makedirs(log_root)
|
||||
|
||||
storage['logfile'] = f"{log_root}/install-session_{self.init_time}.{self.milliseconds}.log"
|
||||
|
||||
file = storage['logfile']
|
||||
|
||||
"""
|
||||
installer.log() wraps output.log() mainly to set a default log-level for this install session.
|
||||
Any manual override can be done per log() call.
|
||||
"""
|
||||
log(*args, level=level, **kwargs)
|
||||
|
||||
def __enter__(self, *args, **kwargs):
|
||||
|
|
|
|||
|
|
@ -37,6 +37,11 @@ class journald(dict):
|
|||
# Fallback logger
|
||||
log_adapter.debug(message)
|
||||
|
||||
# TODO: Replace log() for session based logging.
|
||||
class SessionLogging():
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
# Found first reference here: https://stackoverflow.com/questions/7445658/how-to-detect-if-the-console-does-support-ansi-escape-codes-in-python
|
||||
# And re-used this: https://github.com/django/django/blob/master/django/core/management/color.py#L12
|
||||
def supports_color():
|
||||
|
|
@ -109,6 +114,7 @@ def log(*args, **kwargs):
|
|||
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.
|
||||
# We use sys.stdout.write()+flush() instead of print() to try and
|
||||
# fix issue #94
|
||||
sys.stdout.write(string)
|
||||
sys.stdout.flush()
|
||||
Loading…
Reference in New Issue