Add Logstash file

This commit is contained in:
Mark Veidemanis 2021-08-24 20:08:18 +00:00
parent edc5f85ba6
commit 152bc08970
1 changed files with 19 additions and 0 deletions

19
core/logstash.py Normal file
View File

@ -0,0 +1,19 @@
import logstash
import logging
from json import dumps, loads
import main
from utils.logging.log import *
logger = None
def init_logstash():
global logger
logger = logging.getLogger('ingest')
logger.setLevel(logging.INFO)
logger.addHandler(logstash.TCPLogstashHandler(main.config["Logstash"]["Host"], int(main.config["Logstash"]["Port"]), version=1))
def sendLogstashNotification(text):
if not logger == None:
logger.info(dumps(text))
return True
return False