31 lines
576 B
Python
31 lines
576 B
Python
|
# 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
|