From 6ee50504f33dd0dc50cf6d384418e2f0a1ac8c4c Mon Sep 17 00:00:00 2001 From: Dusty Mabe Date: May 28 2019 14:59:12 +0000 Subject: coreos-koji-tagger: set up logging in main() Remove adding of a handler at the top of the file (this will be handled by fedora messaging for us when running in prod). When testing we'll set up the handler so we get the log statements then. --- diff --git a/coreos_koji_tagger.py b/coreos_koji_tagger.py index 6101297..1c80fbe 100755 --- a/coreos_koji_tagger.py +++ b/coreos_koji_tagger.py @@ -16,9 +16,6 @@ import subprocess # Set local logging logger = logging.getLogger(__name__) -sh = logging.StreamHandler() -sh.setFormatter(logging.Formatter('%(asctime)s %(message)s')) -logger.addHandler(sh) logger.setLevel(logging.INFO) @@ -252,6 +249,10 @@ def add_pkgs_to_tag(tag: str, pkgs: list, owner: str): # If run directly we are just testing. So mock up some of # the data and fake it. if __name__ == '__main__': + sh = logging.StreamHandler() + sh.setFormatter(logging.Formatter('%(asctime)s %(message)s')) + logger.addHandler(sh) + m = fedora_messaging.api.Message( topic = 'io.pagure.prod.pagure.git.receive', body = EXAMPLE_MESSAGE_BODY)