Made logs in jobservice configurable

Signed-off-by: Qian Deng <dengq@vmware.com>
This commit is contained in:
Qian Deng 2019-05-15 10:28:52 +08:00
parent 4188c4db76
commit 1677686140
4 changed files with 13 additions and 7 deletions

View File

@ -70,7 +70,7 @@ chart:
# Log configurations
log:
# options are debug, info, warn, error
# options are debug, info, warning, error, fatal
level: info
# Log files are rotated log_rotate_count times before being removed. If count is 0, old versions are removed rather than rotated.
rotate_count: 50

View File

@ -23,9 +23,9 @@ worker_pool:
#Loggers for the running job
job_loggers:
- name: "STD_OUTPUT" # logger backend name, only support "FILE" and "STD_OUTPUT"
level: "INFO" # INFO/DEBUG/WARNING/ERROR/FATAL
level: "{{level}}" # INFO/DEBUG/WARNING/ERROR/FATAL
- name: "FILE"
level: "INFO"
level: "{{level}}"
settings: # Customized settings of logger
base_dir: "/var/log/jobs"
sweeper:
@ -36,4 +36,4 @@ job_loggers:
#Loggers for the job service
loggers:
- name: "STD_OUTPUT" # Same with above
level: "INFO"
level: "{{level}}"

View File

@ -181,11 +181,15 @@ def parse_yaml_config(config_file_path):
# Log configs
allowed_levels = ['debug', 'info', 'warning', 'error', 'fatal']
log_configs = configs.get('log') or {}
config_dict['log_location'] = log_configs["location"]
config_dict['log_rotate_count'] = log_configs["rotate_count"]
config_dict['log_rotate_size'] = log_configs["rotate_size"]
config_dict['log_level'] = log_configs['level']
log_level = log_configs['level']
if log_level not in allowed_levels:
raise Exception('log level must be one of debug, info, warning, error, fatal')
config_dict['log_level'] = log_level.lower()
# external DB, if external_db enabled, it will cover the database config

View File

@ -14,10 +14,11 @@ jobservice_conf = os.path.join(config_dir, "jobservice", "config.yml")
def prepare_job_service(config_dict):
prepare_config_dir(job_config_dir)
log_level = config_dict['log_level'].upper()
# Job log is stored in data dir
job_log_dir = os.path.join('/data', "job_logs")
prepare_config_dir(job_log_dir)
# Render Jobservice env
render_jinja(
job_service_env_template_path,
@ -31,4 +32,5 @@ def prepare_job_service(config_dict):
uid=DEFAULT_UID,
gid=DEFAULT_GID,
max_job_workers=config_dict['max_job_workers'],
redis_url=config_dict['redis_url_js'])
redis_url=config_dict['redis_url_js'],
level=log_level)