Permalink
Browse files

v2.0.4. Improvement.

- v2.0.4 July 23, 2013
	- Added `lineOffset` configuration offset to allow you to detect the
correct line of the reporting when using wrappers
	- Updated dependencies
  • Loading branch information...
1 parent 7ae5d05 commit ba9698dd99a3990cd4e95e17194a69995d17c2e6 @balupton balupton committed Jul 25, 2013
Showing with 17 additions and 4 deletions.
  1. +4 −0 History.md
  2. +1 −0 README.md
  3. +3 −3 package.json
  4. +9 −1 src/lib/caterpillar.coffee
View
@@ -1,5 +1,9 @@
## History
+- v2.0.4 July 23, 2013
+ - Added `lineOffset` configuration offset to allow you to detect the correct line of the reporting when using wrappers
+ - Updated dependencies
+
- v2.0.3 May 19, 2013
- iOS support (iOS devices do not have `new Error().stack`)
View
@@ -116,6 +116,7 @@ new (require('caterpillar').Logger)(config)
- `getLineInfo()` get the file, method, and line that the `log` method was called on
- Configuration
+ - `lineOffset` the amount of lines to offset when doing our line detection, useful for wrappers, defaults to `0`
- `levels` the level names and their associated number, also includes `default` for when no level was specified, defaults to:
``` javascript
View
@@ -1,6 +1,6 @@
{
"name": "caterpillar",
- "version": "2.0.3",
+ "version": "2.0.4",
"description": "Caterpillar is the ultimate logging system for Node.js, based on transform streams you can log to it and pipe the output off to different locations, including some pre-made ones. Caterpillar also supports log levels according to the RFC standard, as well as line, method, and file fetching for messages. You can even use it in web browsers with caterpillar-browser.",
"homepage": "https://github.com/bevry/caterpillar",
"keywords": [
@@ -26,7 +26,7 @@
"node": ">=0.8"
},
"dependencies": {
- "extendr": "~2.0.1",
+ "extendr": "~2.1.0",
"readable-stream": "~1.0.2"
},
"devDependencies": {
@@ -35,7 +35,7 @@
"coffee-script": "~1.6.2",
"joe": "~1.2.0",
"joe-reporter-console": "~1.2.1",
- "chai": "~1.5.0"
+ "chai": "~1.7.2"
},
"directories": {
"lib": "./out/lib"
@@ -35,6 +35,7 @@ class Transform extends stream.Transform
# Logger
class Logger extends Transform
config:
+ lineOffset: 0
levels:
emergency: 0
alert: 1
@@ -105,8 +106,15 @@ class Logger extends Transform
# Retrieve
err = new Error()
lines = err.stack?.split('\n') or [] # ios devices do not have err.stack available
+ offset = @config.lineOffset
for line in lines
- continue if line.indexOf(__dirname) isnt -1 or line.indexOf(' at ') is -1
+ if line.indexOf(__dirname) isnt -1 or line.indexOf(' at ') is -1
+ continue
+
+ if offset isnt 0
+ --offset
+ continue
+
parts = line.split(':')
if parts[0].indexOf('(') is -1
result.method = 'unknown'

0 comments on commit ba9698d

Please sign in to comment.