acipm / kibicara

Kibicara distributes text messages between different social media and messenger platforms
https://acipm.github.io/kibicara/
Other
2 stars 0 forks source link

[core] Add verbose flag to cli #33

Closed m-rey closed 4 years ago

m-rey commented 4 years ago

This adds a way to capture how verbose the logger should be, based on the amount of v flags you use (so -v vs -vv, for example).

To set the logging level, something like

log = logging.getLogger(__name__) # ignore this if logger already exists
LOGLEVELS = {None: logging.WARNING,  # 0
             0: logging.WARNING,
             1: logging.INFO,
             2: logging.DEBUG,
             }
log.setLevel(LOGLEVELS.get(args.verbose, logging.DEBUG))

could be used

dl6tom commented 4 years ago

Can you add the code to set the log level in https://github.com/acipm/kibicara/blob/0e53b900c07f44066aeeaf0a26b93b3993b3e2a5/kibicara/kibicara.py#L26 to complete this feature? ETA: Would probably make sense to set the global log level with basicConfig to WARNING and then do a getLogger('kibicara').setLevel(...) to only affect the log level for our application. This way we could also get rid of https://github.com/acipm/kibicara/blob/0e53b900c07f44066aeeaf0a26b93b3993b3e2a5/kibicara/kibicara.py#L27