Skip to content

Commit

Permalink
Merge pull request #2 from philmander/log-line-numbers
Browse files Browse the repository at this point in the history
Log line numbers
  • Loading branch information
philmander authored Aug 2, 2016
2 parents e8b8ee9 + 0dd9ee4 commit bf72d81
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 19 deletions.
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,38 @@ The code also contains a dedicated browser console stream. Use it like this:
```javascript
var bunyan = require('./lib/bunyan');
var log = bunyan.createLogger({
name: 'play',
name: 'myLogger',
streams: [
{
level: 'info',
stream: new bunyan.ConsoleFormattedStream()
type: 'raw'
}
]
],
src: true
});

log.info('hi on info');
```

Angular example:

```javascript
adminApp.config(function($provide) {
$provide.decorator('$log', function($delegate) {
$delegate = bunyan.createLogger({
name: 'myLogger',
streams: [{
level: 'info',
stream: new bunyan.ConsoleFormattedStream(),
type: 'raw'
}]
});
return $delegate;
});
});
```

Docs are the Bunyan docs at time of forking, with the documentation for the stripped features also removed:

=====================================
Expand Down
16 changes: 8 additions & 8 deletions dist/browser-bunyan.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* -*- mode: js -*-
* vim: expandtab:ts=4:sw=4
*/

'use strict';

var VERSION = '0.2.3';
Expand Down Expand Up @@ -227,7 +227,6 @@ Object.keys(levelFromName).forEach(function (name) {
nameFromLevel[levelFromName[name]] = name;
});


/**
* Resolve a level number, name (upper or lowercase) to a level number value.
*
Expand All @@ -238,7 +237,6 @@ function resolveLevel(nameOrNum) {
return level;
}


//---- Logger class

/**
Expand Down Expand Up @@ -771,16 +769,18 @@ function mkLogEmitter(minLevel) {
}
// Get call source info
if (log.src && !rec.src) {
var src = extractSrcFromStacktrace(new Error(CALL_STACK_ERROR).stack, 2);
if(!src) {
if(!_haveWarned('src')) {
try {
//need to throw the error so there is a stack in IE
throw new Error(CALL_STACK_ERROR);
} catch(err) {
var src = extractSrcFromStacktrace(err.stack, 2);
if(!src && !_haveWarned('src')) {
_warn('Unable to determine src line info', 'src');
}
rec.src = src || '';
}
rec.src = src || '';
}
rec.v = LOG_VERSION;

return rec;
}

Expand Down
Loading

0 comments on commit bf72d81

Please sign in to comment.