Skip to content
This repository has been archived by the owner on Apr 21, 2022. It is now read-only.

Commit

Permalink
ensure nodejs library can pass an env parameter with the line
Browse files Browse the repository at this point in the history
  • Loading branch information
respectus committed Jul 25, 2017
1 parent 90b62c2 commit 8a52e5c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
26 changes: 24 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ var options = {
hostname: myHostname,
ip: ipAddress,
mac: macAddress,
app: appName
app: appName,
env: envName
};

// Defaults to false, when true ensures meta object will be searchable
Expand Down Expand Up @@ -141,6 +142,16 @@ Max Length: `32`

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

##### env

_**Optional**_
Type: `String`
Default: `''`
Values: `YourCustomEnvironment`
Max Length: `32`

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

##### index_meta

_**Optional**_
Expand Down Expand Up @@ -253,6 +264,16 @@ Max Length: `32`

The app passed along with this log line.

##### env

_**Optional**_
Type: `String`
Default: `''`
Values: `YourCustomEnvironment`
Max Length: `32`

The environment passed along with this log line.

##### meta

_**Optional**_
Expand Down Expand Up @@ -301,7 +322,8 @@ var options = {
hostname: myHostname,
ip: ipAddress,
mac: macAddress,
app: appName
app: appName,
env: envName
};

// Defaults to false, when true ensures meta object will be searchable
Expand Down
3 changes: 3 additions & 0 deletions lib/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ function Logger(key, options) {
hostname: options.hostname || os.hostname()
, app: options.app || 'default'
, level: options.level || 'INFO'
, env: options.env || undefined
};

this._req = request.defaults({
Expand Down Expand Up @@ -106,6 +107,7 @@ Logger.prototype.log = function(statement, opts) {
, line: statement
, level: this.source.level
, app: this.source.app
, env: this.source.env
};
if (opts) {
if (_.isString(opts)) {
Expand All @@ -121,6 +123,7 @@ Logger.prototype.log = function(statement, opts) {
}
message.level = opts.level || message.level;
message.app = opts.app || message.app;
message.env = opts.env || message.env;
if (opts.timestamp && isValidTimestamp(opts.timestamp)) {
message.timestamp = opts.timestamp;
}
Expand Down

0 comments on commit 8a52e5c

Please sign in to comment.