Skip to content

Commit 687c0dd

Browse files
committed
remove old LogstashFormatterVersion0
1 parent 7916fb0 commit 687c0dd

8 files changed

+15
-49
lines changed

MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ include LICENSE
22
include README.rst
33
include example1.py
44
include example2.py
5+
include example3.py

README.rst

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ http://logstash.net/
1212

1313
Changelog
1414
=========
15+
0.5.1
16+
- New Config for Field / Stacktrace Limit
17+
- Removed Version 0 (old scheme)
1518
0.5.0
1619
- New HTTP Handler
1720
0.4.8

logstash/formatter.py

+1-30
Original file line numberDiff line numberDiff line change
@@ -106,37 +106,8 @@ def serialize(cls, message):
106106
else:
107107
return bytes(json.dumps(message), 'utf-8')
108108

109-
class LogstashFormatterVersion0(LogstashFormatterBase):
110-
version = 0
111109

112-
def format(self, record):
113-
# Create message dict
114-
message = {
115-
'@timestamp': self.format_timestamp(record.created),
116-
'@message': record.getMessage(),
117-
'@source': self.format_source(self.message_type, self.host,
118-
record.pathname),
119-
'@source_host': self.host,
120-
'@source_path': record.pathname,
121-
'@tags': self.tags,
122-
'@type': self.message_type,
123-
'@fields': {
124-
'levelname': record.levelname,
125-
'logger': record.name,
126-
},
127-
}
128-
129-
# Add extra fields
130-
message['@fields'].update(self.get_extra_fields(record))
131-
132-
# If exception, add debug info
133-
if record.exc_info:
134-
message['@fields'].update(self.get_debug_fields(record))
135-
136-
return self.serialize(message)
137-
138-
139-
class LogstashFormatterVersion1(LogstashFormatterBase):
110+
class LogstashFormatter(LogstashFormatterBase):
140111

141112
def format(self, record):
142113
# Create message dict

logstash/handler_amqp.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ class AMQPLogstashHandler(SocketHandler, object):
3333
3434
:param tags: list of tags for a logger (default is None).
3535
:param message_type: The type of the message (default logstash).
36-
:param version: version of logstash event schema (default is 0).
3736
3837
:param extra_fields: Send extra fields on the log record to graylog
3938
if true (the default)
@@ -46,7 +45,7 @@ class AMQPLogstashHandler(SocketHandler, object):
4645
def __init__(self, host='localhost', port=5672, username='guest',
4746
password='guest', exchange='logstash', exchange_type='fanout',
4847
virtual_host='/', message_type='logstash', tags=None,
49-
durable=False, passive=False, version=0, extra_fields=True,
48+
durable=False, passive=False, extra_fields=True,
5049
fqdn=False, facility=None, exchange_routing_key=''):
5150

5251

@@ -66,9 +65,7 @@ def __init__(self, host='localhost', port=5672, username='guest',
6665

6766
# Extract Logstash paramaters
6867
self.tags = tags or []
69-
fn = formatter.LogstashFormatterVersion1 if version == 1 \
70-
else formatter.LogstashFormatterVersion0
71-
self.formatter = fn(message_type, tags, fqdn)
68+
self.formatter = formatter.LogstashFormatter(message_type, tags, fqdn)
7269

7370
# Standard logging parameters
7471
self.extra_fields = extra_fields

logstash/handler_http.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,17 @@ class HTTPLogstashHandler(NullHandler, object):
1414
:param ssl: Use SSL for logstash server (default False).
1515
:param message_type: The type of the message (default logstash).
1616
:param fqdn; Indicates whether to show fully qualified domain name or not (default False).
17-
:param version: version of logstash event schema (default is 0).
1817
:param tags: list of tags for a logger (default is None).
1918
:param verify: verify ssl (default is True)
2019
:param username: basic_auth user (default is None)
2120
:param password: basic_auth user (default is None)
2221
"""
2322

24-
def __init__(self, host, port=80, ssl=False, message_type='logstash', tags=None, fqdn=False, version=0, verify=True, username=None, password=None):
23+
def __init__(self, host, port=80, ssl=False, message_type='logstash', tags=None, fqdn=False, verify=True, username=None, password=None):
2524
super(NullHandler, self).__init__()
26-
if version == 1:
27-
self.formatter = formatter.LogstashFormatterVersion1(message_type, tags, fqdn)
28-
else:
29-
self.formatter = formatter.LogstashFormatterVersion0(message_type, tags, fqdn)
25+
26+
self.formatter = formatter.LogstashFormatter(message_type, tags, fqdn)
27+
3028
if username and password:
3129
self.auth = HTTPBasicAuth(username, password)
3230
else:

logstash/handler_tcp.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,13 @@ class TCPLogstashHandler(SocketHandler, object):
1010
:param port: The port of the logstash server (default 5959).
1111
:param message_type: The type of the message (default logstash).
1212
:param fqdn; Indicates whether to show fully qualified domain name or not (default False).
13-
:param version: version of logstash event schema (default is 0).
1413
:param tags: list of tags for a logger (default is None).
1514
"""
1615

17-
def __init__(self, host, port=5959, message_type='logstash', tags=None, fqdn=False, version=0):
16+
def __init__(self, host, port=5959, message_type='logstash', tags=None, fqdn=False):
1817
super(TCPLogstashHandler, self).__init__(host, port)
19-
if version == 1:
20-
self.formatter = formatter.LogstashFormatterVersion1(message_type, tags, fqdn)
21-
else:
22-
self.formatter = formatter.LogstashFormatterVersion0(message_type, tags, fqdn)
18+
19+
self.formatter = formatter.LogstashFormatter(message_type, tags, fqdn)
2320

2421
def makePickle(self, record):
2522
return self.formatter.format(record) + b'\n'

logstash/handler_udp.py

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ class UDPLogstashHandler(TCPLogstashHandler, DatagramHandler):
99
:param port: The port of the logstash server (default 5959).
1010
:param message_type: The type of the message (default logstash).
1111
:param fqdn; Indicates whether to show fully qualified domain name or not (default False).
12-
:param version: version of logstash event schema (default is 0).
1312
:param tags: list of tags for a logger (default is None).
1413
"""
1514

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
setup(
33
name='python-logstash-nested',
44
packages=['logstash'],
5-
version='0.4.9',
5+
version='0.5.1',
66
description='Python logging handler for Logstash.',
77
long_description=open('README.rst').read(),
88
license='MIT',

0 commit comments

Comments
 (0)