forked from SAP/cf-nodejs-logging-support
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
67 lines (54 loc) · 1.97 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//loading core logger functionality
var coreLogger = require("./cf-nodejs-logging-support-core/log-core");
var effectiveLogger = null;
coreLogger.init();
effectiveLogger = require("./cf-nodejs-logging-support-express/log-express");
defaultConfig = require("./config.js");
effectiveLogger.setCoreLogger(coreLogger);
effectiveLogger.setConfig(defaultConfig.config);
exports.setLoggingLevel = function (level) {
effectiveLogger.setLoggingLevel(level);
};
exports.forceLogger = function (name) {
switch (name) {
//insert your custom framework logger here
case "restify":
effectiveLogger = require("./cf-nodejs-logging-support-restify/log-restify");
break;
case "plainhttp":
effectiveLogger = require("./cf-nodejs-logging-support-plainhttp/log-plainhttp");
break;
default:
effectiveLogger = require("./cf-nodejs-logging-support-express/log-express");
}
effectiveLogger.setCoreLogger(coreLogger);
effectiveLogger.setConfig(defaultConfig.config);
};
exports.logNetwork = function (req, res, next) {
effectiveLogger.logNetwork(req, res, next);
};
exports.logMessage = function (args) {
effectiveLogger.logMessage.apply(this, arguments);
};
coreLogger.bindConvenienceMethods(exports);
exports.createWinstonTransport = function (options) {
if (!options) {
options = {
level: 'info'
};
}
options.logMessage = effectiveLogger.logMessage;
return require("./cf-nodejs-logging-support-winston/winston-transport").createTransport(options);
};
exports.getCorrelationObject = function () {
return effectiveLogger.getCorrelationObject();
};
exports.createCorrelationObject = function () {
return coreLogger.createCorrelationObject();
}
exports.setLogPattern = function (args) {
effectiveLogger.setLogPattern.apply(this, arguments);
};
exports.overrideNetworkField = function (args) {
effectiveLogger.overrideField.apply(this, arguments);
};