Skip to content

Commit

Permalink
Merge pull request #5 from jitsi/disable-caller-info
Browse files Browse the repository at this point in the history
Disable caller info
  • Loading branch information
saghul authored Aug 23, 2019
2 parents 5da3033 + 7234f55 commit a885cc9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/LogCollector.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright @ 2016 Atlassian Pty Ltd
/* Copyright @ 2016-present 8x8, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
21 changes: 18 additions & 3 deletions lib/Logger.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright @ 2015 Atlassian Pty Ltd
/* Copyright @ 2015-present 8x8, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -60,6 +60,19 @@ Logger.removeGlobalTransport = function(transport) {
}
};

/**
* The global configuration options.
*/
var globalOptions = {};

/**
* Sets global options which will be used by all loggers. Changing these works
* even after other loggers are created.
*/
Logger.setGlobalOptions = function(options) {
globalOptions = options || {};
}

/**
* Parses Error's object stack trace and extracts information about the last
* caller before the log method was called.
Expand Down Expand Up @@ -115,7 +128,9 @@ function log() {
return;
}

var callerInfo = !logger.options.disableCallerInfo && getCallerInfo();
var callerInfo
= !(logger.options.disableCallerInfo
|| globalOptions.disableCallerInfo) && getCallerInfo();
var transports = globalTransports.concat(logger.transports);
for(var i = 0; i < transports.length; i++) {
var t = transports[i];
Expand All @@ -127,7 +142,7 @@ function log() {
logPrefixes.push("[" + logger.id + "]");
}

if (callerInfo) {
if (callerInfo && callerInfo.methodName.length > 1) {
logPrefixes.push("<" + callerInfo.methodName + ">: ");
}

Expand Down
9 changes: 8 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright @ 2015 Atlassian Pty Ltd
/* Copyright @ 2015-present 8x8, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -67,6 +67,13 @@ module.exports = {
removeGlobalTransport: function(transport) {
Logger.removeGlobalTransport(transport);
},
/**
* Sets global options which will be used by all loggers. Changing these
* works even after other loggers are created.
*/
setGlobalOptions: function(options) {
Logger.setGlobalOptions(options);
},
/**
* Creates new logger.
* @arguments the same as Logger constructor
Expand Down

0 comments on commit a885cc9

Please sign in to comment.