Commit 729d24fc authored by Daniele Venzano's avatar Daniele Venzano

Add option to save logs into a file

parent a1d2dd32
......@@ -41,10 +41,13 @@ def zoe_web_main() -> int:
"""
config.load_configuration()
args = config.get_conf()
if args.debug:
logging.basicConfig(level=logging.DEBUG, format=LOG_FORMAT)
else:
logging.basicConfig(level=logging.INFO, format=LOG_FORMAT)
log_args = {
'level': logging.DEBUG if args.debug else logging.INFO,
'format': LOG_FORMAT
}
if args.log_file != "stderr":
log_args['filename'] = args.log_file
logging.basicConfig(**log_args)
if config.get_conf().auth_type == 'ldap' and not zoe_api.auth.ldap.LDAP_AVAILABLE:
log.error("LDAP authentication requested, but 'pyldap' module not installed.")
......
......@@ -98,6 +98,7 @@ def load_configuration(test_conf=None):
argparser.add_argument('--kube-config-file', help='Kubernetes configuration file', default='/opt/zoe/kube.conf')
argparser.add_argument('--cookie-secret', help='secret used to encrypt cookies', default='changeme')
argparser.add_argument('--log-file', help='output logs to a file', default='stderr')
opts = argparser.parse_args()
if opts.debug:
......
......@@ -40,11 +40,12 @@ def main():
"""
config.load_configuration()
args = config.get_conf()
if args.debug:
logging.basicConfig(level=logging.DEBUG, format=LOG_FORMAT)
else:
logging.basicConfig(level=logging.INFO, format=LOG_FORMAT)
log_args = {
'level': logging.DEBUG if args.debug else logging.INFO,
'format': LOG_FORMAT
}
if args.log_file != "stderr":
log_args['filename'] = args.log_file
if config.get_conf().influxdb_enable:
metrics = InfluxDBMetricSender(config.get_conf().deployment_name, config.get_conf().influxdb_url, config.get_conf().influxdb_dbname)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment