From 40dbbef3d7189d89e613e11058741dbfb8114e38 Mon Sep 17 00:00:00 2001 From: fabrixxm Date: Wed, 11 Aug 2021 21:03:04 +0200 Subject: Per-module logger, add cli switch to log debug when using lesana as a library, having a per-module logger is better instead of logging everything in root. When `lesana` cli command is used, logger is configured to print simple logline and loglevel is set to INFO, unless user pass the option `-v` or `--verbose` which sets the level to DEBUG --- scripts/lesana | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/lesana b/scripts/lesana index 51d5f7a..8f38a67 100755 --- a/scripts/lesana +++ b/scripts/lesana @@ -2,7 +2,7 @@ """ Lesana Command Line interface """ - +import logging import lesana.command @@ -26,4 +26,13 @@ class Lesana(lesana.command.MainCommand): if __name__ == "__main__": + + # setup logging for lesana cli + logger = logging.getLogger('lesana') + ch = logging.StreamHandler() + formatter = logging.Formatter('%(levelname)s: %(message)s') + ch.setFormatter(formatter) + logger.addHandler(ch) + logger.setLevel(logging.INFO) + Lesana().main() -- cgit v1.2.3