From 4ec85020f6e54e8fdc4b2edfdbbcd1330d9ad9a5 Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Mon, 12 Mar 2018 08:10:19 +0800 Subject: [PATCH] Add LOG_FORMAT envvar to control logging format. --- docs/ENVIRONMENT.rst | 9 ++++++++- electrumx_server.py | 5 ++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/ENVIRONMENT.rst b/docs/ENVIRONMENT.rst index 58735bd..588d91b 100644 --- a/docs/ENVIRONMENT.rst +++ b/docs/ENVIRONMENT.rst @@ -64,9 +64,16 @@ Miscellaneous These environment variables are optional: +* **LOG_FORMAT** + + The Python logging `format string + `_ + to use. Defaults to `%(levelname)s:%(name)s:%(message)s`. + * **ALLOW_ROOT** - Set this environment variable to anything non-empty to allow running ElectrumX as root. + Set this environment variable to anything non-empty to allow running + ElectrumX as root. * **NET** diff --git a/electrumx_server.py b/electrumx_server.py index 0e94279..fdb0198 100755 --- a/electrumx_server.py +++ b/electrumx_server.py @@ -18,9 +18,8 @@ from server.controller import Controller def main(): '''Set up logging and run the server.''' - logging.basicConfig(level=logging.INFO, - format='%(asctime)s %(levelname)-7s %(message)-100s ' - '[%(filename)s:%(lineno)d]') + log_fmt = Env.default('LOG_FORMAT', '%(levelname)s:%(name)s:%(message)s') + logging.basicConfig(level=logging.INFO, format=log_fmt) logging.info('ElectrumX server starting') try: controller = Controller(Env())