diff --git a/aprsd/main.py b/aprsd/main.py index d0b621e..2bf476f 100644 --- a/aprsd/main.py +++ b/aprsd/main.py @@ -177,8 +177,8 @@ def signal_handler(sig, frame): def setup_logging(config, loglevel, quiet): log_level = LOG_LEVELS[loglevel] LOG.setLevel(log_level) - log_format = "[%(asctime)s] [%(threadName)-12s] [%(levelname)-5.5s]" " %(message)s" - date_format = "%m/%d/%Y %I:%M:%S %p" + log_format = config["aprsd"].get("logformat", utils.DEFAULT_LOG_FORMAT) + date_format = config["aprsd"].get("dateformat", utils.DEFAULT_DATE_FORMAT) log_formatter = logging.Formatter(fmt=log_format, datefmt=date_format) log_file = config["aprsd"].get("logfile", None) if log_file: diff --git a/aprsd/utils.py b/aprsd/utils.py index 8b84cea..c101fe5 100644 --- a/aprsd/utils.py +++ b/aprsd/utils.py @@ -11,6 +11,13 @@ from aprsd import plugin import click import yaml +DEFAULT_LOG_FORMAT = ( + "[%(asctime)s] [%(threadName)-12s] [%(levelname)-5.5s]" + " %(message)s - [%(pathname)s.%(funcName)s:%(lineno)d]" +) + +DEFAULT_DATE_FORMAT = "%m/%d/%Y %I:%M:%S %p" + # an example of what should be in the ~/.aprsd/config.yml DEFAULT_CONFIG_DICT = { "ham": {"callsign": "CALLSIGN"}, @@ -22,6 +29,8 @@ DEFAULT_CONFIG_DICT = { }, "aprsd": { "logfile": "/tmp/aprsd.log", + "logformat": DEFAULT_LOG_FORMAT, + "dateformat": DEFAULT_DATE_FORMAT, "trace": False, "plugin_dir": "~/.config/aprsd/plugins", "enabled_plugins": plugin.CORE_PLUGINS,