Config gets a new elastic field for logging to dynamic elastic host.

This commit is contained in:
2019-04-30 19:24:36 +02:00
parent 206606ca1e
commit 506a029a88
2 changed files with 10 additions and 1 deletions

View File

@@ -8,3 +8,7 @@ local=
[DELUGE] [DELUGE]
script= script=
[ELASTIC]
host=
port=

View File

@@ -5,6 +5,8 @@ import os
import json import json
import urllib.request import urllib.request
from utils import getConfig
BASE_DIR = os.path.dirname(os.path.abspath(__file__)) BASE_DIR = os.path.dirname(os.path.abspath(__file__))
LOG_FILE = os.path.join(BASE_DIR, 'output.log') LOG_FILE = os.path.join(BASE_DIR, 'output.log')
@@ -45,7 +47,10 @@ class ESHandler(logging.Handler):
response = response.read().decode('utf8') response = response.read().decode('utf8')
return response 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) eh.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s %(levelname)8s | %(message)s') formatter = logging.Formatter('%(asctime)s %(levelname)8s | %(message)s')