Created
April 21, 2014 07:57
-
-
Save shimdh/11135563 to your computer and use it in GitHub Desktop.
extended winston logger in node.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "use strict"; | |
| /** | |
| * Created by zizisky on 14. 4. 20. | |
| */ | |
| Object.defineProperty(global, '__stack', { | |
| get: function() { | |
| var orig = Error.prepareStackTrace; | |
| Error.prepareStackTrace = function(_, stack) { | |
| return stack; | |
| }; | |
| var err = new Error(); | |
| Error.captureStackTrace(err, arguments.callee); | |
| var stack = err.stack; | |
| Error.prepareStackTrace = orig; | |
| return stack; | |
| } | |
| }); | |
| Object.defineProperty(global, '__line', { | |
| get: function() { | |
| return __stack[1].getLineNumber(); | |
| } | |
| }); | |
| Object.defineProperty(global, '__function', { | |
| get: function() { | |
| return __stack[1].getFunctionName(); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment