1010@loggify
1111class InitramfsGenerator (GeneratorHelpers ):
1212 def __init__ (self , config = '/etc/ugrd/config.toml' , * args , ** kwargs ):
13- self .config_dict = InitramfsConfigDict (NO_BASE = kwargs .pop ('NO_BASE' , False ), logger = self .logger )
13+ self .config_dict = InitramfsConfigDict (NO_BASE = kwargs .pop ('NO_BASE' , False ), logger = self .logger , _log_init = False )
1414
1515 # Used for functions that are added to the bash source file
1616 self .included_functions = {}
@@ -71,8 +71,10 @@ def __getattr__(self, item):
7171
7272 def build (self ) -> None :
7373 """ Builds the initramfs image. """
74+ from importlib .metadata import version
75+ self ._log_run (f"Running ugrd v{ version ('ugrd' )} " )
7476 self .run_build ()
75- self .config_dict .validate ()
77+ self .config_dict .validate () # Validate the config after the build tasks have been run
7678
7779 self .generate_init ()
7880 self .pack_build ()
@@ -201,12 +203,14 @@ def generate_init(self) -> None:
201203
202204 def run_build (self ) -> None :
203205 """ Runs all build tasks. """
206+ self ._log_run ("Running build tasks" )
204207 for task in self .build_tasks :
205208 self .logger .debug ("Running build task: %s" % task )
206209 self .run_hook (task , force_exclude = True )
207210
208211 def pack_build (self ) -> None :
209212 """ Packs the initramfs based on self['imports']['pack']."""
213+ self ._log_run ("Packing build" )
210214 if self ['imports' ].get ('pack' ):
211215 self .run_hook ('pack' )
212216 else :
@@ -224,8 +228,8 @@ def run_init_hook(self, level: str) -> list[str]:
224228
225229 def run_checks (self ) -> None :
226230 """ Runs checks if defined in self['imports']['checks']. """
231+ self ._log_run ("Running checks" )
227232 if check_output := self .run_hook ('checks' ):
228- self .logger .info ("Completed checks." )
229233 for check in check_output :
230234 self .logger .debug (check )
231235 else :
@@ -234,10 +238,14 @@ def run_checks(self) -> None:
234238 def run_tests (self ) -> None :
235239 """ Runs tests if defined in self['imports']['tests']. """
236240 if test_output := self .run_hook ('tests' ):
241+ self ._log_run ("Running tests" )
237242 self .logger .info ("Completed tests:\n %s" , test_output )
238243 else :
239244 self .logger .debug ("No tests executed." )
240245
246+ def _log_run (self , logline ) -> None :
247+ self .logger .info (f"== | { logline } " )
248+
241249 def __str__ (self ) -> str :
242250 return str (self .config_dict )
243251
0 commit comments