Skip to content

Commit

Permalink
[AIRFLOW-1337] Allow log format customization via airflow.cfg
Browse files Browse the repository at this point in the history
Closes apache#2392 from ronfung/customize-logging-thru-config
  • Loading branch information
Ron Fung authored and criccomini committed Jun 23, 2017
1 parent ebed532 commit 4841e3e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
6 changes: 6 additions & 0 deletions airflow/config_templates/default_airflow.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ s3_log_folder =
# Logging level
logging_level = INFO

# Log format
LOG_FORMAT = [%%(asctime)s] {{%%(filename)s:%%(lineno)d}} %%(levelname)s - %%(message)s
LOG_FORMAT_WITH_PID = [%%(asctime)s] [%%(process)d] {{%%(filename)s:%%(lineno)d}} %%(levelname)s - %%(message)s
LOG_FORMAT_WITH_THREAD_NAME = [%%(asctime)s] {{%%(filename)s:%%(lineno)d}} %%(threadName)s %%(levelname)s - %%(message)s
SIMPLE_LOG_FORMAT = %%(asctime)s %%(levelname)s - %%(message)s

# Size of logging buffer
logging_buffer_size = 4096
# Logging level minimum to flush buffer before full
Expand Down
2 changes: 1 addition & 1 deletion airflow/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
warnings.filterwarnings(
action='default', category=PendingDeprecationWarning, module='airflow')

ConfigParser = configparser.ConfigParser
ConfigParser = configparser.SafeConfigParser


def generate_fernet_key():
Expand Down
12 changes: 4 additions & 8 deletions airflow/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,10 @@ def timing(cls, stat, dt):
# the prefix to append to gunicorn worker processes after init
GUNICORN_WORKER_READY_PREFIX = "[ready] "

# can't move this to conf due to ConfigParser interpolation
LOG_FORMAT = (
'[%(asctime)s] {%(filename)s:%(lineno)d} %(levelname)s - %(message)s')
LOG_FORMAT_WITH_PID = (
'[%(asctime)s] [%(process)d] {%(filename)s:%(lineno)d} %(levelname)s - %(message)s')
LOG_FORMAT_WITH_THREAD_NAME = (
'[%(asctime)s] {%(filename)s:%(lineno)d} %(threadName)s %(levelname)s - %(message)s')
SIMPLE_LOG_FORMAT = '%(asctime)s %(levelname)s - %(message)s'
LOG_FORMAT = conf.get('core', 'LOG_FORMAT')
LOG_FORMAT_WITH_PID = conf.get('core', 'LOG_FORMAT_WITH_PID')
LOG_FORMAT_WITH_THREAD_NAME = conf.get('core', 'LOG_FORMAT_WITH_THREAD_NAME')
SIMPLE_LOG_FORMAT = conf.get('core', 'SIMPLE_LOG_FORMAT')

AIRFLOW_HOME = None
SQL_ALCHEMY_CONN = None
Expand Down

0 comments on commit 4841e3e

Please sign in to comment.