2020-08-04 14:52:30 +00:00
|
|
|
#!/usr/bin/env python3
|
2020-08-12 15:46:50 +00:00
|
|
|
|
|
|
|
# system
|
2020-08-10 12:05:19 +00:00
|
|
|
import logging
|
|
|
|
|
2020-08-12 15:46:50 +00:00
|
|
|
# local
|
2021-09-28 10:17:53 +00:00
|
|
|
import kiwi_scp
|
2020-08-04 14:52:30 +00:00
|
|
|
|
|
|
|
|
2020-08-10 12:39:28 +00:00
|
|
|
def set_verbosity(logger, handler, verbosity):
|
2020-08-13 08:48:01 +00:00
|
|
|
"""set logging default verbosity level and format"""
|
|
|
|
|
2020-08-10 12:39:28 +00:00
|
|
|
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))
|
2020-08-10 12:05:19 +00:00
|
|
|
|
2020-08-10 12:39:28 +00:00
|
|
|
|
|
|
|
def main():
|
2020-08-13 08:48:01 +00:00
|
|
|
# add a new handler (needed to set the level)
|
2020-08-10 12:39:28 +00:00
|
|
|
log_handler = logging.StreamHandler()
|
|
|
|
logging.getLogger().addHandler(log_handler)
|
2021-09-28 10:17:53 +00:00
|
|
|
set_verbosity(logging.getLogger(), log_handler, kiwi_scp.verbosity())
|
2020-08-11 10:08:03 +00:00
|
|
|
|
2020-08-13 08:48:01 +00:00
|
|
|
# run the app
|
2021-09-28 10:17:53 +00:00
|
|
|
if not kiwi_scp.run():
|
2020-08-19 15:42:09 +00:00
|
|
|
quit(1)
|
2020-08-04 14:52:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|