diff --git a/README.md b/README.md index e0b4354..b45c15c 100644 --- a/README.md +++ b/README.md @@ -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_ @@ -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_ diff --git a/logdna/logdna.py b/logdna/logdna.py index 65ca506..be1c925 100644 --- a/logdna/logdna.py +++ b/logdna/logdna.py @@ -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 @@ -90,7 +91,8 @@ 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'] @@ -98,6 +100,8 @@ def emit(self, record): 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: