Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,15 @@ The default level passed along with every log sent through this instance.
By default the line has a maximum length of 16000 chars, this can be turned off with the value false.


##### tags

* _Optional_
* Type: `String[]`
* Default: `[]`

List of tags used to dynamically group hosts. More information on tags is available at [How Do I Use Host Tags?](https://docs.logdna.com/docs/logdna-agent#section-how-do-i-use-host-tags-)


### log(line, [options])
---
#### line
Expand Down
15 changes: 14 additions & 1 deletion logdna/logdna.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ def __init__(self, key, options={}):
self.env = options['env'] if 'env' in options else ''
self.setLevel(logging.DEBUG)

self.tags = []
if 'tags' in options and isinstance(options['tags'], list):
self.tags.extend(options['tags'])
self.max_length = True
if 'max_length' in options:
self.max_length = options['max_length']
Expand Down Expand Up @@ -71,7 +74,17 @@ def flush(self):
self.flusher = Timer(defaults['FLUSH_NOW'], self.flush)
self.flusher.start()
else:
resp = requests.post(url=defaults['LOGDNA_URL'], json=data, auth=('user', self.key), params={ 'hostname': self.hostname, 'ip': self.ip, 'mac': self.mac if self.mac else None }, stream=True, timeout=defaults['MAX_REQUEST_TIMEOUT'])
resp = requests.post(
url=defaults['LOGDNA_URL'],
json=data,
auth=('user', self.key),
params={
'hostname': self.hostname,
'ip': self.ip,
'mac': self.mac if self.mac else None,
'tags': self.tags if self.tags else None},
stream=True,
timeout=defaults['MAX_REQUEST_TIMEOUT'])
self.buf = []
self.bufByteLength = 0
if self.flusher:
Expand Down