monolith/core/logstash.py

29 lines
566 B
Python
Raw Normal View History

2021-08-24 20:08:18 +00:00
import logstash
import logging
from json import dumps, loads
import main
from utils.logging.log import *
logger = None
2022-07-21 12:39:41 +00:00
2021-08-24 20:08:18 +00:00
def init_logstash():
global logger
2022-07-21 12:39:41 +00:00
logger = logging.getLogger("ingest")
2021-08-24 20:08:18 +00:00
logger.setLevel(logging.INFO)
2022-07-21 12:39:41 +00:00
logger.addHandler(
logstash.TCPLogstashHandler(
main.config["Logstash"]["Host"],
int(main.config["Logstash"]["Port"]),
version=1,
)
)
2021-08-24 20:08:18 +00:00
def sendLogstashNotification(text):
if not logger == None:
logger.info(dumps(text))
return True
return False