levenlabs-log
Advanced tools
Comparing version 0.1.0 to 0.1.1
## Changelog ## | ||
### 0.1.1 ### | ||
* Don't treat rpc errors as an Error | ||
### 0.1.0 ### | ||
* Handle `keyVals` being a string or number | ||
* Stable release | ||
* Added `LLOG_LEVEL` env variable parsing | ||
@@ -7,0 +11,0 @@ ### 0.0.2 ### |
@@ -110,7 +110,10 @@ if (typeof require === 'function') { | ||
//if its an error and has a message, otherwise just fallback to toString() | ||
if (val.hasOwnProperty('message')) { | ||
//specifically look for data since rpc "errors" contain those and we | ||
//don't want to treat those as errors | ||
if (val instanceof Error || (val.hasOwnProperty('message') && val.hasOwnProperty('code') && !val.hasOwnProperty('data'))) { | ||
str = val.message; | ||
if (val.hasOwnProperty('code')) { | ||
return val.message + ' (Code: ' + val.code + ')'; | ||
str += ' (Code: ' + val.code + ')'; | ||
} | ||
return val.message; | ||
return str | ||
} | ||
@@ -117,0 +120,0 @@ if (typeof val.toString === 'function') { |
{ | ||
"name": "levenlabs-log", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Leven Labs Logging", | ||
@@ -5,0 +5,0 @@ "main": "log.js", |
@@ -181,2 +181,4 @@ var logFilename = '../log.js', | ||
test.equal(lastWrite, '~ [date] DEBUG -- -- error="test (Code: 1)"\n'); | ||
log.debug('', {error: {message: 'test', code: 1, data: 'hey'}}); | ||
test.equal(lastWrite, '~ [date] DEBUG -- -- error="{\\"message\\":\\"test\\",\\"code\\":1,\\"data\\":\\"hey\\"}"\n'); | ||
test.done(); | ||
@@ -183,0 +185,0 @@ }; |
17866
440