32 lines
577 B
Python
32 lines
577 B
Python
# Other library imports
|
|
import logging
|
|
from json import dumps
|
|
|
|
import logstash
|
|
|
|
# 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
|