vm-manager: Added log console printing on vm start. Added python logging module
This commit is contained in:
@@ -117,10 +117,10 @@ def main() -> None:
|
||||
parser.print_help()
|
||||
|
||||
if args.debug:
|
||||
setup_logging(logging.DEBUG)
|
||||
setup_logging(logging.DEBUG, root_log_name=__name__.split(".")[0])
|
||||
log.debug("Debug log activated")
|
||||
else:
|
||||
setup_logging(logging.INFO)
|
||||
setup_logging(logging.INFO, root_log_name=__name__.split(".")[0])
|
||||
|
||||
if not hasattr(args, "func"):
|
||||
return
|
||||
|
||||
@@ -66,9 +66,9 @@ def get_caller() -> str:
|
||||
return ret
|
||||
|
||||
|
||||
def setup_logging(level: Any) -> None:
|
||||
def setup_logging(level: Any, root_log_name: str = __name__.split(".")[0]) -> None:
|
||||
# Get the root logger and set its level
|
||||
main_logger = logging.getLogger("clan_cli")
|
||||
main_logger = logging.getLogger(root_log_name)
|
||||
main_logger.setLevel(level)
|
||||
|
||||
# Create and add the default handler
|
||||
|
||||
@@ -102,7 +102,6 @@ class Machine:
|
||||
system = config["system"]
|
||||
|
||||
attr = f'clanInternals.machines."{system}".{self.name}.{attr}'
|
||||
print(f"attr: {attr}")
|
||||
|
||||
if attr in self.eval_cache and not refresh:
|
||||
return self.eval_cache[attr]
|
||||
@@ -115,9 +114,8 @@ class Machine:
|
||||
else:
|
||||
flake = self.flake
|
||||
|
||||
print(f"evaluating {flake}#{attr}")
|
||||
cmd = nix_eval([f"{flake}#{attr}"])
|
||||
print(f"cmd: {cmd}")
|
||||
|
||||
output = run(cmd).stdout.strip()
|
||||
self.eval_cache[attr] = output
|
||||
return output
|
||||
|
||||
Reference in New Issue
Block a user