From b98850819bdbdb23e354bb5bf5d5383cf807d22d Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Wed, 4 Nov 2020 22:41:50 +0100 Subject: Added multiple log features. * [Reintroduced](https://github.com/Torxed/archinstall/blob/f64a605449f59c677dff39962f1cb46616d893b7/archinstall.py#L57-L71) log levels * Created a global log file definition * Optional support for `python-systemd`'s journald handler. * Optional file output that has a globally configurable definition, that archinstall will honor in `archinstall.storage['logfile']`. --- archinstall/lib/disk.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'archinstall/lib/disk.py') diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py index 0d0285d2..6ac97b04 100644 --- a/archinstall/lib/disk.py +++ b/archinstall/lib/disk.py @@ -2,6 +2,7 @@ import glob, re, os, json from collections import OrderedDict from .exceptions import DiskError from .general import * +from .output import log, LOG_LEVELS ROOT_DIR_PATTERN = re.compile('^.*?/devices') GPT = 0b00000001 @@ -115,7 +116,7 @@ class Partition(): return f'Partition(path={self.path}, fs={self.filesystem}, mounted={self.mountpoint})' def format(self, filesystem): - log(f'Formatting {self} -> {filesystem}') + log(f'Formatting {self} -> {filesystem}', level=LOG_LEVELS.Info, file=storage.get('logfile', None)) if filesystem == 'btrfs': o = b''.join(sys_command(f'/usr/bin/mkfs.btrfs -f {self.path}')) if b'UUID' not in o: @@ -154,7 +155,7 @@ class Partition(): def mount(self, target, fs=None, options=''): if not self.mountpoint: - log(f'Mounting {self} to {target}') + log(f'Mounting {self} to {target}', level=LOG_LEVELS.Info, file=storage.get('logfile', None)) if not fs: if not self.filesystem: raise DiskError(f'Need to format (or define) the filesystem on {self} before mounting.') fs = self.filesystem @@ -216,7 +217,7 @@ class Filesystem(): self.add_partition('primary', start='513MiB', end='100%', format='ext4') def add_partition(self, type, start, end, format=None): - log(f'Adding partition to {self.blockdevice}') + log(f'Adding partition to {self.blockdevice}', level=LOG_LEVELS.Info, file=storage.get('logfile', None)) if format: return self.parted(f'{self.blockdevice.device} mkpart {type} {format} {start} {end}') == 0 else: -- cgit v1.2.3-70-g09d2 From baf2ef1128c645c75a6ced3c3c91ce1c2147642d Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Wed, 4 Nov 2020 23:37:53 +0000 Subject: Forgot an import of storage. --- archinstall/lib/disk.py | 1 + 1 file changed, 1 insertion(+) (limited to 'archinstall/lib/disk.py') diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py index 6ac97b04..e50f1b08 100644 --- a/archinstall/lib/disk.py +++ b/archinstall/lib/disk.py @@ -3,6 +3,7 @@ from collections import OrderedDict from .exceptions import DiskError from .general import * from .output import log, LOG_LEVELS +from .storage import storage ROOT_DIR_PATTERN = re.compile('^.*?/devices') GPT = 0b00000001 -- cgit v1.2.3-70-g09d2