Browse Source

add verbose option to enable debug logging from the command line

Helmut Pozimski 7 years ago
parent
commit
bd5fab8038
2 changed files with 9 additions and 2 deletions
  1. 2 1
      README.md
  2. 7 1
      amulib/main.py

+ 2 - 1
README.md

@@ -18,8 +18,9 @@ acme-updater can be called with the following command line arguments:
 * --dovecot
 * --ejabberd
 * --config / -C
+* --verbose / -V
 
-The ones corresponding to service names enable the module for the service to take care of maintaining the certificates for it. The config argument expects a path to the configuration file as parameter.
+The ones corresponding to service names enable the module for the service to take care of maintaining the certificates for it. The config argument expects a path to the configuration file as parameter. Verbose overrides any log level set in the configuration file and enables debug logging.
 
 
 ## Dependencies

+ 7 - 1
amulib/main.py

@@ -44,6 +44,9 @@ def main():
                         action="store_true")
     parser.add_argument("--ejabberd", help="use the ejabberd module",
                         action="store_true")
+    parser.add_argument("--verbose", "-V", help="be verbose, enables debug "
+                                                "output",
+                        action="store_true")
     parser.add_argument("--config", "-C", help="path to the configuration "
                                                "file", type=str)
     args = parser.parse_args()
@@ -59,7 +62,10 @@ def main():
         except json.JSONDecodeError:
             logger.error("Error: Could not parse configuration file")
             sys.exit(1)
-    logger.setLevel(get_log_level(config["loglevel"]))
+    if args.verbose:
+        logger.setLevel(logging.DEBUG)
+    else:
+        logger.setLevel(get_log_level(config["loglevel"]))
     if args.apache:
         if config:
             apache.run(config["apache"], config["acme_dir"],