Skip to content

Commit

Permalink
Merge pull request #3 from dabrign/json-formatting-log
Browse files Browse the repository at this point in the history
Formatting in json the log
  • Loading branch information
dabrign committed Aug 14, 2018
2 parents da3e92f + 76d6210 commit 7859568
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion splunk_handler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def __init__(self, host, port, token, index,
hostname=None, source=None, sourcetype='text',
verify=True, timeout=60, flush_interval=15.0,
queue_size=5000, debug=False, retry_count=5,
retry_backoff=2.0, protocol='https', proxies = None):
retry_backoff=2.0, protocol='https', proxies = None,
record_format = False):

global instances
instances.append(self)
Expand All @@ -75,6 +76,7 @@ def __init__(self, host, port, token, index,
self.retry_backoff = retry_backoff
self.protocol = protocol
self.proxies = proxies
self.record_format = record_format

self.write_debug_log("Starting debug mode")

Expand Down Expand Up @@ -170,6 +172,11 @@ def format_record(self, record):
if self.testing:
current_time = None

if self.record_format:
try:
record = json.dumps(record)
except:
pass

params = {
'time': current_time,
Expand Down

0 comments on commit 7859568

Please sign in to comment.