mirror of
https://github.com/KevinMidboe/transatlanticTorrentExpress.git
synced 2025-10-29 18:00:19 +00:00
Create a session id each time ES handler is initialized
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import logging
|
||||
import os
|
||||
import json
|
||||
import uuid
|
||||
import urllib.request
|
||||
|
||||
from utils import getConfig
|
||||
@@ -27,6 +28,7 @@ class ESHandler(logging.Handler):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.host = kwargs.get('host')
|
||||
self.port = kwargs.get('port') or 9200
|
||||
self.sessionID = uuid.uuid4()
|
||||
|
||||
logging.StreamHandler.__init__(self)
|
||||
|
||||
@@ -37,7 +39,8 @@ class ESHandler(logging.Handler):
|
||||
doc = {
|
||||
'severity': record.levelname,
|
||||
'message': record.message,
|
||||
'@timestamp': int(record.created*1000)
|
||||
'@timestamp': int(record.created*1000),
|
||||
'sessionID': self.sessionID
|
||||
}
|
||||
|
||||
payload = json.dumps(doc).encode('utf8')
|
||||
|
||||
Reference in New Issue
Block a user