Skip to content

Commit

Permalink
ensure python module can also pass an environment parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
respectus committed Jul 25, 2017
1 parent 6bdfb16 commit 20b2ecc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ Max Length: `32`

The default app passed along with every log sent through this instance.

##### env

_Optional_
Type: `String`
Default: `''`
Values: `YourCustomEnv`
Max Length: `32`

The default env passed along with every log sent through this instance.

##### hostname

_Optional_
Expand Down Expand Up @@ -183,6 +193,16 @@ Max Length: `32`

The app passed along with this log line.

##### env

_Optional_
Type: `String`
Default: `''`
Values: `YourCustomEnv`
Max Length: `32`

The environment passed with this log line.

##### meta

_Optional_
Expand Down
6 changes: 5 additions & 1 deletion logdna/logdna.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def __init__(self, token, options={}):
self.hostname = options['hostname'] if 'hostname' in options else gethostname()
self.level = options['level'] if 'level' in options else 'info'
self.app = options['app'] if 'app' in options else ''
self.env = options['env'] if 'env' in options else ''
self.setLevel(logging.DEBUG)

self.max_length = True
Expand Down Expand Up @@ -90,14 +91,17 @@ def emit(self, record):
'timestamp': int(time.time()),
'line': msg,
'level': record['levelname'] or self.level,
'app': self.app or record['module']
'app': self.app or record['module'],
'env': self.env
}
if 'level' in opts:
message['level'] = opts['level']
if 'app' in opts:
message['app'] = opts['app']
if 'hostname' in opts:
message['hostname'] = opts['hostname']
if 'env' in opts:
message['env'] = opts['env']
if 'timestamp' in opts:
message['timestamp'] = opts['timestamp']
if 'meta' in opts:
Expand Down

0 comments on commit 20b2ecc

Please sign in to comment.