mirror of
https://github.com/yavook/kiwi-scp.git
synced 2024-11-25 05:53:00 +00:00
39 lines
976 B
Python
Executable file
39 lines
976 B
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
# system
|
|
import logging
|
|
|
|
# local
|
|
import kiwi_scp
|
|
|
|
|
|
def set_verbosity(logger, handler, verbosity):
|
|
"""set logging default verbosity level and format"""
|
|
|
|
if verbosity >= 2:
|
|
log_level = logging.DEBUG
|
|
log_format = "[%(asctime)s] %(levelname)s @ %(filename)s:%(funcName)s:%(lineno)d: %(message)s"
|
|
elif verbosity >= 1:
|
|
log_level = logging.INFO
|
|
log_format = "[%(asctime)s] %(levelname)s: %(message)s"
|
|
else:
|
|
log_level = logging.WARNING
|
|
log_format = "%(levelname)s: %(message)s"
|
|
|
|
logger.setLevel(log_level)
|
|
handler.setFormatter(logging.Formatter(log_format))
|
|
|
|
|
|
def main():
|
|
# add a new handler (needed to set the level)
|
|
log_handler = logging.StreamHandler()
|
|
logging.getLogger().addHandler(log_handler)
|
|
set_verbosity(logging.getLogger(), log_handler, kiwi_scp.verbosity())
|
|
|
|
# run the app
|
|
if not kiwi_scp.run():
|
|
quit(1)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|