monolith/legacy/core/logstash.py

28 lines
527 B
Python

import logging
from json import dumps
import logstash
import main
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 logger is not None:
logger.info(dumps(text))
return True
return False