Skip to content

Commit 7815498

Browse files
committed
Merge pull request #4 from alexk-blackops/master
Logger name fix + stack trace source method fix
2 parents 63204b8 + 92106e7 commit 7815498

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

config/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ module.exports = {
2020
IDENTIFY_DELAY: 300000, // 5 minutes delay if identifyApp call failed
2121
COOKIE_MASK: 'X-MASKED-X', // cookie headers and values mask
2222
LOGGER_VERSION: 'Node.js Stackify v.1.0',
23+
WINSTON_LOGGER_VERSION: 'Node.js Winston-Stackify v.1.0',
2324
X_STACKIFY_PV: 'V1'
2425
};

index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
var api = require('./lib/api'), // wrappers for API calls
22
exception = require('./lib/exception'), // exception handler module
3-
logger = require('./lib/logger'); // logging methods module
3+
logger = require('./lib/logger'), // logging methods module
4+
CONFIG = require('./config/config');
45

56
module.exports = {
67
// start sending logs
78
start: function (options) {
9+
CONFIG.SELECTED_LOGGER = CONFIG.LOGGER_VERSION;
810
api.methods.identifyApp(options);
911
exception.catchException(options.exitOnError || false);
1012
exception.gracefulExitHandler();
@@ -19,6 +21,12 @@ module.exports = {
1921

2022
//common method for handling logged messages
2123
push: logger.methods.push,
24+
// setting logger name to Winston logger if it's used
25+
setLoggerName: function (name) {
26+
if (name === 'Winston') {
27+
CONFIG.SELECTED_LOGGER = CONFIG.WINSTON_LOGGER_VERSION;
28+
}
29+
},
2230

2331
expressExceptionHandler: exception.expressExceptionHandler
2432
};

lib/helpers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ module.exports.getTrace = function getTrace(err) {
9494
trace.forEach(function (val) {
9595
var method = val.methodName || (val.functionName || val.typeName) + '.<anonymous>';
9696

97-
if (val.fileName ? (val.fileName.search('lib/logger.js') < 0 || val.fileName.search('stackify') < 0) : true) {
97+
if (val.fileName ? (val.fileName.search('lib/logger.js') < 0 && val.fileName.search('stackify') < 0) : true) {
9898
result.push({
9999
CodeFileName: val.fileName,
100100
LineNum: val.lineNumber,
@@ -146,7 +146,7 @@ module.exports.getPostBody = function getPostBody(messages) {
146146
ServerName: os.hostname(),
147147
AppName: CONFIG.APPNAME,
148148
AppLoc: process.env.PWD,
149-
Logger: CONFIG.LOGGER_VERSION,
149+
Logger: CONFIG.SELECTED_LOGGER,
150150
Platform: 'nodejs',
151151
Msgs : messages
152152
};

0 commit comments

Comments
 (0)