mirror of
https://github.com/craigerl/aprsd.git
synced 2024-12-19 16:15:57 -05:00
Added log format and dateformat to config file
This patch moves the default log format string and date format string to the config file, so users can format the logs as they see fit. The default log format also includes the file and line number that posted the log entry. The new entries in the config are here: aprsd: logformat: "String here" dateformat: "string here"
This commit is contained in:
parent
239e784d51
commit
0a038dae44
@ -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:
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user