mirror of
https://github.com/craigerl/aprsd.git
synced 2025-08-04 22:32:29 -04:00
Updated aprsd-dev to use config for logfile format
This patch updates the aprsd-dev command's log file format to use what's defined as the default and/or use the config file setting like aprsd server does.
This commit is contained in:
parent
14f77876f9
commit
2bf85db21b
21
aprsd/dev.py
21
aprsd/dev.py
@ -121,14 +121,23 @@ def install(append, case_insensitive, shell, path):
|
|||||||
# to disable logging to stdout, but still log to file
|
# to disable logging to stdout, but still log to file
|
||||||
# use the --quiet option on the cmdln
|
# use the --quiet option on the cmdln
|
||||||
def setup_logging(config, loglevel, quiet):
|
def setup_logging(config, loglevel, quiet):
|
||||||
log_level = LOG_LEVELS[loglevel]
|
log_level = aprsd_config.LOG_LEVELS[loglevel]
|
||||||
LOG.setLevel(log_level)
|
LOG.setLevel(log_level)
|
||||||
log_format = "[%(asctime)s] [%(threadName)-12s] [%(levelname)-5.5s]" " %(message)s"
|
log_format = config["aprsd"].get(
|
||||||
date_format = "%m/%d/%Y %I:%M:%S %p"
|
"logformat",
|
||||||
|
aprsd_config.DEFAULT_LOG_FORMAT,
|
||||||
|
)
|
||||||
|
date_format = config["aprsd"].get(
|
||||||
|
"dateformat",
|
||||||
|
aprsd_config.DEFAULT_DATE_FORMAT,
|
||||||
|
)
|
||||||
log_formatter = logging.Formatter(fmt=log_format, datefmt=date_format)
|
log_formatter = logging.Formatter(fmt=log_format, datefmt=date_format)
|
||||||
log_file = config["aprs"].get("logfile", None)
|
log_file = config["aprsd"].get("logfile", None)
|
||||||
if log_file:
|
if log_file:
|
||||||
fh = RotatingFileHandler(log_file, maxBytes=(10248576 * 5), backupCount=4)
|
fh = RotatingFileHandler(
|
||||||
|
log_file, maxBytes=(10248576 * 5),
|
||||||
|
backupCount=4,
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
fh = NullHandler()
|
fh = NullHandler()
|
||||||
|
|
||||||
@ -181,8 +190,8 @@ def test_plugin(
|
|||||||
"""APRSD Plugin test app."""
|
"""APRSD Plugin test app."""
|
||||||
|
|
||||||
config = aprsd_config.parse_config(config_file)
|
config = aprsd_config.parse_config(config_file)
|
||||||
|
|
||||||
setup_logging(config, loglevel, False)
|
setup_logging(config, loglevel, False)
|
||||||
|
|
||||||
LOG.info(f"Test APRSD PLugin version: {aprsd.__version__}")
|
LOG.info(f"Test APRSD PLugin version: {aprsd.__version__}")
|
||||||
if type(message) is tuple:
|
if type(message) is tuple:
|
||||||
message = " ".join(message)
|
message = " ".join(message)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user