Comparing version 1.1.1 to 2.0.0
@@ -13,2 +13,2 @@ export declare type LogMethod = (msg: string, meta?: any) => ILogger; | ||
export declare const makeLogger: (options?: ILoggerOptions) => ILogger; | ||
export declare const wipeSensitiveHeaders: (meta: any) => any; | ||
export declare const wipeSensitiveData: (meta: any) => any; |
'use strict' | ||
Object.defineProperty(exports, '__esModule', { value: true }) | ||
var winston = require('winston') | ||
var environment = (typeof process !== 'undefined' && process.env.NODE_ENV) || 'development' | ||
var util_1 = require('util') | ||
var winston_1 = require('winston') | ||
var environment = | ||
(typeof process !== 'undefined' && process.env.NODE_ENV && process.env.NODE_ENV.trim()) || | ||
'development' | ||
var isDevelopment = environment === 'development' | ||
var customFormat = isDevelopment | ||
? winston_1.format.combine( | ||
winston_1.format.metadata(), | ||
winston_1.format.timestamp(), | ||
winston_1.format.colorize(), | ||
// format.prettyPrint() | ||
winston_1.format.printf(function(info) { | ||
var str = '[' + info.timestamp + '] ' + info.level + ': ' + info.message | ||
if (info.metadata && Object.keys(info.metadata).length > 0) { | ||
str += '\n' + util_1.inspect(info.metadata, false, null, true) | ||
} | ||
return str | ||
}) | ||
) | ||
: winston_1.format.combine(winston_1.format.timestamp(), winston_1.format.logstash()) | ||
exports.makeLogger = function(options) { | ||
@@ -14,23 +32,14 @@ if (options === void 0) { | ||
: defaultOptions.wipeSensitiveData | ||
return new winston.Logger({ | ||
var wipeSensitiveDataFormat = winston_1.format(function(meta) { | ||
return options.wipeSensitiveData(meta) | ||
}) | ||
return winston_1.createLogger({ | ||
level: options.logLevel, | ||
exitOnError: false, | ||
handleExceptions: true, | ||
rewriters: [ | ||
function(level, msg, meta) { | ||
if (meta) { | ||
return options.wipeSensitiveData(meta) | ||
} | ||
return meta | ||
} | ||
], | ||
format: isDevelopment | ||
? customFormat | ||
: winston_1.format.combine(wipeSensitiveDataFormat(), customFormat), | ||
transports: [ | ||
new winston.transports.Console({ | ||
colorize: true, | ||
humanReadableUnhandledException: isDevelopment, | ||
json: !isDevelopment, | ||
level: options.logLevel, | ||
logstash: !isDevelopment, | ||
prettyPrint: isDevelopment, | ||
stringify: !isDevelopment, | ||
timestamp: true | ||
new winston_1.transports.Console({ | ||
handleExceptions: true | ||
}) | ||
@@ -40,12 +49,6 @@ ] | ||
} | ||
exports.wipeSensitiveHeaders = function(meta) { | ||
var request = meta.req | ||
if (!request || !request.headers || isDevelopment) { | ||
return meta | ||
} | ||
delete request.headers.authorization | ||
delete request.headers.cookie | ||
exports.wipeSensitiveData = function(meta) { | ||
return meta | ||
} | ||
var defaultOptions = { logLevel: 'debug', wipeSensitiveData: exports.wipeSensitiveHeaders } | ||
var defaultOptions = { logLevel: 'debug', wipeSensitiveData: exports.wipeSensitiveData } | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "loggerism", | ||
"version": "1.1.1", | ||
"version": "2.0.0", | ||
"description": "Yet another logger abstraction", | ||
@@ -24,12 +24,12 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"winston": "^2.4.2" | ||
"winston": "^3.1.0" | ||
}, | ||
"devDependencies": { | ||
"@types/winston": "^2.3.9", | ||
"@types/node": "^10.11.5", | ||
"precommit-hook": "^3.0.0", | ||
"prettier": "^1.12.1", | ||
"prettier": "^1.14.3", | ||
"rimraf": "^2.6.2", | ||
"tslint": "^5.10.0", | ||
"tslint-config-prettier": "^1.13.0", | ||
"typescript": "^2.8.3" | ||
"tslint": "^5.11.0", | ||
"tslint-config-prettier": "^1.15.0", | ||
"typescript": "^3.1.1" | ||
}, | ||
@@ -36,0 +36,0 @@ "files": [ |
@@ -5,2 +5,2 @@ # Yet another logger abstraction | ||
Currently use [winston 2](https://github.com/winstonjs/winston) for default implementation but this is likely to be changed to more productive loggers like [pino](https://github.com/pinojs/pino) or [winson 3](https://github.com/winstonjs/winston). | ||
Currently use [winston 3](https://github.com/winstonjs/winston) for default implementation but this is likely to be changed to more productive loggers like [pino](https://github.com/pinojs/pino). |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5419
65
3
+ Added@colors/colors@1.6.0(transitive)
+ Added@dabh/diagnostics@2.0.3(transitive)
+ Added@types/triple-beam@1.3.5(transitive)
+ Addedasync@3.2.6(transitive)
+ Addedcolor@3.2.1(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addedcolor-string@1.9.1(transitive)
+ Addedcolorspace@1.1.4(transitive)
+ Addedenabled@2.0.0(transitive)
+ Addedfecha@4.2.3(transitive)
+ Addedfn.name@1.1.0(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedis-arrayish@0.3.2(transitive)
+ Addedis-stream@2.0.1(transitive)
+ Addedkuler@2.0.0(transitive)
+ Addedlogform@2.7.0(transitive)
+ Addedms@2.1.3(transitive)
+ Addedone-time@1.0.0(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsafe-stable-stringify@2.5.0(transitive)
+ Addedsimple-swizzle@0.2.2(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addedtext-hex@1.0.0(transitive)
+ Addedtriple-beam@1.4.1(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedwinston@3.17.0(transitive)
+ Addedwinston-transport@4.9.0(transitive)
- Removedasync@2.6.4(transitive)
- Removedcolors@1.0.3(transitive)
- Removedcycle@1.0.3(transitive)
- Removedeyes@0.1.8(transitive)
- Removedisstream@0.1.2(transitive)
- Removedlodash@4.17.21(transitive)
- Removedwinston@2.4.7(transitive)
Updatedwinston@^3.1.0