added integration with source-map-support for integration with sourcemaps

Style updates, changelog, etc. Fixes #122
This commit is contained in:
Trent Mick 2015-01-17 21:15:38 -08:00
parent 1ed684d110
commit 83f33890de
3 changed files with 16 additions and 0 deletions

View file

@ -18,3 +18,4 @@ Andrei Neculau (https://github.com/andreineculau)
Mihai Tomescu (https://github.com/matomesc)
Daniel Juhl (https://github.com/danieljuhl)
Chris Barber (https://github.com/cb1kenobi)
Manuel Schneider (https://github.com/manuelschneider)

View file

@ -8,6 +8,11 @@ Known issues:
## bunyan 1.3.1 (not yet released)
- [pull #122] Source Map support for caller line position for [the "src"
field](https://github.com/trentm/node-bunyan#src). This could be interesting
for [CoffeeScript](http://coffeescript.org/documentation/docs/sourcemap.html)
users of Bunyan. By Manuel Schneider.
- [issue #164] Ensure a top-level `level` given in `bunyan.createLogger`
is *used* for given `streams`. For example, ensure that the following
results in the stream having a DEBUG level:

View file

@ -50,6 +50,12 @@ try {
var isBrowser = function () {
return typeof (window) !== 'undefined' && this === window; }();
try {
var sourceMapSupport = require("source-map-support");
} catch (_) {
sourceMapSupport = null;
}
//---- Internal support stuff
@ -126,8 +132,12 @@ function getCaller3Info() {
var savePrepare = Error.prepareStackTrace;
Error.stackTraceLimit = 3;
Error.captureStackTrace(this, getCaller3Info);
Error.prepareStackTrace = function (_, stack) {
var caller = stack[2];
if (sourceMapSupport) {
caller = sourceMapSupport.wrapCallSite(caller);
}
obj.file = caller.getFileName();
obj.line = caller.getLineNumber();
var func = caller.getFunctionName();