From 506a029a88c44e97eb35db03fce68afdf8d869dc Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Tue, 30 Apr 2019 19:24:36 +0200 Subject: [PATCH] Config gets a new elastic field for logging to dynamic elastic host. --- config.ini.default | 4 ++++ logger.py | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/config.ini.default b/config.ini.default index 02e65e3..70184e5 100644 --- a/config.ini.default +++ b/config.ini.default @@ -8,3 +8,7 @@ local= [DELUGE] script= + +[ELASTIC] +host= +port= diff --git a/logger.py b/logger.py index 47d7590..d14e43e 100644 --- a/logger.py +++ b/logger.py @@ -5,6 +5,8 @@ import os import json import urllib.request +from utils import getConfig + BASE_DIR = os.path.dirname(os.path.abspath(__file__)) LOG_FILE = os.path.join(BASE_DIR, 'output.log') @@ -45,7 +47,10 @@ class ESHandler(logging.Handler): response = response.read().decode('utf8') return response -eh = ESHandler(host='localhost') +config = getConfig() +esHost = config['ELASTIC']['host'] +esPort = config['ELASTIC']['port'] +eh = ESHandler(host=esHost, port=esPort) eh.setLevel(logging.DEBUG) formatter = logging.Formatter('%(asctime)s %(levelname)8s | %(message)s')