pluto/handler/lib/logstash.py

31 lines
576 B
Python
Raw Normal View History

2022-06-19 17:24:22 +00:00
# Other library imports
from json import dumps
import logstash
import logging
# Project imports
from settings import settings
logger = None
def init_logstash():
global logger
logger = logging.getLogger("ingest")
logger.setLevel(logging.INFO)
logger.addHandler(
logstash.TCPLogstashHandler(
settings.Logstash.Host,
int(settings.Logstash.Port),
version=1,
)
)
def send_logstash(text):
global logger
if logger is not None:
logger.info(dumps(text))
return True
return False