]> git-server-git.apps.pok.os.sepia.ceph.com Git - radosgw-agent.git/commitdiff
configure logging before parsing arguments wip-11245 26/head
authorAlfredo Deza <adeza@redhat.com>
Thu, 26 Mar 2015 19:01:57 +0000 (15:01 -0400)
committerAlfredo Deza <adeza@redhat.com>
Thu, 26 Mar 2015 19:01:57 +0000 (15:01 -0400)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
radosgw_agent/cli.py

index 75ea1f28951c6c52be66984383a586e1bad82074..fa736ce6700236fe043d7493ccadfe2ee9d91d15 100644 (file)
@@ -313,8 +313,6 @@ def set_args_to_config(args):
 
 @catches((KeyboardInterrupt, RuntimeError, AgentError,), handle_all=True)
 def main():
-    args = parse_args()
-
     # root (a.k.a. 'parent') and agent loggers
     root_logger = logging.getLogger()
 
@@ -323,18 +321,19 @@ def main():
 
     # Console handler, meant only for user-facing information
     console_loglevel = logging.INFO
-    if args.verbose:
-        console_loglevel = logging.DEBUG
-    elif args.quiet:
-        console_loglevel = logging.WARN
 
     sh = logging.StreamHandler()
     sh.setFormatter(util.log.color_format())
+    # this console level set here before reading options from the arguments
+    # so that we can get errors if they pop up before
     sh.setLevel(console_loglevel)
 
     agent_logger = logging.getLogger('radosgw_agent')
     agent_logger.addHandler(sh)
 
+    # After initial logging is configured, now parse args
+    args = parse_args()
+
     # File handler
     log_file = args.log_file or 'radosgw-agent.log'
     try:
@@ -351,6 +350,15 @@ def main():
 
     root_logger.addHandler(fh)
 
+    if args.verbose:
+        console_loglevel = logging.DEBUG
+    elif args.quiet:
+        console_loglevel = logging.WARN
+
+    # now that we have parsed the actual log level we need
+    # reset it in the handler
+    sh.setLevel(console_loglevel)
+
     # after loggin is set ensure that the arguments are present in the
     # config object
     set_args_to_config(args)