Comparing version 2.3.10 to 2.3.11
'use strict' | ||
Object.defineProperty(exports, '__esModule', { value: true }) | ||
exports.isDevelopment = exports.environment = void 0 | ||
exports.environment = | ||
@@ -4,0 +5,0 @@ (typeof process !== 'undefined' && process.env.NODE_ENV && process.env.NODE_ENV.trim()) || |
@@ -6,3 +6,5 @@ export declare const dumpError: (e: Error) => { | ||
callstack: string | undefined; | ||
raw: string; | ||
}; | ||
}; | ||
export declare const getRaw: (e: Error) => string; |
'use strict' | ||
Object.defineProperty(exports, '__esModule', { value: true }) | ||
exports.dumpError = function(e) { | ||
exports.getRaw = exports.dumpError = void 0 | ||
var serialize_error_1 = require('serialize-error') | ||
var dumpError = function(e) { | ||
return { | ||
@@ -8,6 +10,14 @@ error: { | ||
message: e.message, | ||
callstack: e.stack | ||
callstack: e.stack, | ||
raw: (0, exports.getRaw)(e) | ||
} | ||
} | ||
} | ||
exports.dumpError = dumpError | ||
var getRaw = function(e) { | ||
var result = JSON.stringify((0, serialize_error_1.serializeError)(e)) | ||
// If we got a html page as an error content agreed cut it to not break the logging | ||
return result.length > 8000 ? result.substr(0, 8000) : result | ||
} | ||
exports.getRaw = getRaw | ||
//# sourceMappingURL=error.js.map |
'use strict' | ||
Object.defineProperty(exports, '__esModule', { value: true }) | ||
exports.customFormat = void 0 | ||
var util_1 = require('util') | ||
@@ -13,6 +14,9 @@ var winston_1 = require('winston') | ||
winston_1.format.printf(function(info) { | ||
var str = '[' + info.timestamp + '] ' + info.level + ': ' + info.message | ||
var str = '[' | ||
.concat(info.timestamp, '] ') | ||
.concat(info.level, ': ') | ||
.concat(info.message) | ||
if (info.metadata && Object.keys(info.metadata).length > 0) { | ||
// tslint:disable-next-line:no-console | ||
str += '\n' + util_1.inspect(info.metadata, false, null, true) | ||
str += '\n' + (0, util_1.inspect)(info.metadata, false, null, true) | ||
} | ||
@@ -19,0 +23,0 @@ return str |
'use strict' | ||
Object.defineProperty(exports, '__esModule', { value: true }) | ||
exports.dumpError = exports.wrapLogger = exports.wipeSensitiveData = exports.makeLogger = void 0 | ||
var logger_1 = require('./logger') | ||
exports.makeLogger = logger_1.makeLogger | ||
exports.wipeSensitiveData = logger_1.wipeSensitiveData | ||
Object.defineProperty(exports, 'makeLogger', { | ||
enumerable: true, | ||
get: function() { | ||
return logger_1.makeLogger | ||
} | ||
}) | ||
Object.defineProperty(exports, 'wipeSensitiveData', { | ||
enumerable: true, | ||
get: function() { | ||
return logger_1.wipeSensitiveData | ||
} | ||
}) | ||
var wrap_1 = require('./wrap') | ||
exports.wrapLogger = wrap_1.wrapLogger | ||
Object.defineProperty(exports, 'wrapLogger', { | ||
enumerable: true, | ||
get: function() { | ||
return wrap_1.wrapLogger | ||
} | ||
}) | ||
var error_1 = require('./error') | ||
exports.dumpError = error_1.dumpError | ||
Object.defineProperty(exports, 'dumpError', { | ||
enumerable: true, | ||
get: function() { | ||
return error_1.dumpError | ||
} | ||
}) | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
export declare type LogMethod<T extends object = object> = (msg: string | Error, meta?: T | Error) => ILogger<T>; | ||
export type LogMethod<T extends object = object> = (msg: string | Error, meta?: T | Error) => ILogger<T>; | ||
export interface ILogger<T extends object = object> { | ||
@@ -13,3 +13,3 @@ error: LogMethod<T>; | ||
} | ||
export declare const makeLogger: <T extends object = object>(customOptions?: ILoggerOptions | undefined) => ILogger<T>; | ||
export declare const makeLogger: <T extends object = object>(customOptions?: ILoggerOptions) => ILogger<T>; | ||
export declare const wipeSensitiveData: (meta: any) => any; |
@@ -17,2 +17,3 @@ 'use strict' | ||
Object.defineProperty(exports, '__esModule', { value: true }) | ||
exports.wipeSensitiveData = exports.makeLogger = void 0 | ||
var winston_1 = require('winston') | ||
@@ -22,8 +23,8 @@ var env_1 = require('./env') | ||
var format_1 = require('./format') | ||
exports.makeLogger = function(customOptions) { | ||
var options = __assign({}, defaultOptions, customOptions) | ||
var wipeSensitiveDataFormat = winston_1.format(function(meta) { | ||
var makeLogger = function(customOptions) { | ||
var options = __assign(__assign({}, defaultOptions), customOptions) | ||
var wipeSensitiveDataFormat = (0, winston_1.format)(function(meta) { | ||
return options.wipeSensitiveData(meta) | ||
}) | ||
var logger = winston_1.createLogger({ | ||
var logger = (0, winston_1.createLogger)({ | ||
level: options.logLevel, | ||
@@ -43,5 +44,5 @@ exitOnError: false, | ||
if (msg instanceof Error) { | ||
logger[level](msg.name, __assign({}, meta, error_1.dumpError(msg))) | ||
logger[level](msg.name, __assign(__assign({}, meta), (0, error_1.dumpError)(msg))) | ||
} else if (meta instanceof Error) { | ||
logger[level](msg, error_1.dumpError(meta)) | ||
logger[level](msg, (0, error_1.dumpError)(meta)) | ||
} else { | ||
@@ -67,5 +68,7 @@ logger[level](msg, meta) | ||
} | ||
exports.wipeSensitiveData = function(meta) { | ||
exports.makeLogger = makeLogger | ||
var wipeSensitiveData = function(meta) { | ||
return meta | ||
} | ||
exports.wipeSensitiveData = wipeSensitiveData | ||
var defaultOptions = { | ||
@@ -72,0 +75,0 @@ logLevel: 'debug', |
@@ -17,13 +17,17 @@ 'use strict' | ||
Object.defineProperty(exports, '__esModule', { value: true }) | ||
exports.wrapLogger = void 0 | ||
var error_1 = require('./error') | ||
exports.wrapLogger = function(logger, baseMeta, convertMeta) { | ||
var wrapLogger = function(logger, baseMeta, convertMeta) { | ||
var defaultMeta = convertMeta ? convertMeta(baseMeta) : baseMeta | ||
var log = function(level, msg, meta) { | ||
if (msg instanceof Error) { | ||
logger[level](msg.message, __assign({}, defaultMeta, error_1.dumpError(msg))) | ||
logger[level](msg.message, __assign(__assign({}, defaultMeta), (0, error_1.dumpError)(msg))) | ||
} else if (meta instanceof Error) { | ||
logger[level](msg, __assign({}, defaultMeta, error_1.dumpError(meta))) | ||
logger[level](msg, __assign(__assign({}, defaultMeta), (0, error_1.dumpError)(meta))) | ||
return wrappedLogger | ||
} else if (meta) { | ||
logger[level](msg, __assign({}, defaultMeta, convertMeta ? convertMeta(meta) : meta)) | ||
logger[level]( | ||
msg, | ||
__assign(__assign({}, defaultMeta), convertMeta ? convertMeta(meta) : meta) | ||
) | ||
} else { | ||
@@ -50,2 +54,3 @@ logger[level](msg, defaultMeta) | ||
} | ||
exports.wrapLogger = wrapLogger | ||
//# sourceMappingURL=wrap.js.map |
@@ -11,2 +11,6 @@ export declare const convertMeta: ({ snapshot, operation, service }: { | ||
} | undefined; | ||
}) => {}; | ||
}) => { | ||
service_name?: string | undefined; | ||
operation_id?: string | undefined; | ||
snapshot_id?: string | undefined; | ||
}; |
@@ -17,7 +17,9 @@ 'use strict' | ||
Object.defineProperty(exports, '__esModule', { value: true }) | ||
exports.convertMeta = void 0 | ||
// tslint:disable:no-unused-expression | ||
// tslint:disable-next-line:no-implicit-dependencies | ||
var chai_1 = require('chai') | ||
var error_1 = require('./error') | ||
var index_1 = require('./index') | ||
exports.convertMeta = function(_a) { | ||
var convertMeta = function(_a) { | ||
var snapshot = _a.snapshot, | ||
@@ -27,8 +29,10 @@ operation = _a.operation, | ||
return __assign( | ||
{}, | ||
snapshot ? { snapshot_id: snapshot.id } : undefined, | ||
operation ? { operation_id: operation.id } : undefined, | ||
__assign( | ||
__assign({}, snapshot ? { snapshot_id: snapshot.id } : undefined), | ||
operation ? { operation_id: operation.id } : undefined | ||
), | ||
service ? { service_name: service.name } : undefined | ||
) | ||
} | ||
exports.convertMeta = convertMeta | ||
var makeLoggerStub = function() { | ||
@@ -67,6 +71,6 @@ var result = { | ||
result = _a.result | ||
var wrappedLogger = index_1.wrapLogger(logger, { operation: { id: 'operation1' } }) | ||
var wrappedLogger = (0, index_1.wrapLogger)(logger, { operation: { id: 'operation1' } }) | ||
wrappedLogger.info('test1') | ||
chai_1.expect(result.info[0].meta).deep.eq({ operation: { id: 'operation1' } }) | ||
chai_1.expect(result.info[0].msg).eq('test1') | ||
;(0, chai_1.expect)(result.info[0].meta).deep.eq({ operation: { id: 'operation1' } }) | ||
;(0, chai_1.expect)(result.info[0].msg).eq('test1') | ||
}) | ||
@@ -77,3 +81,3 @@ it('if convertMeta provided', function() { | ||
result = _a.result | ||
var wrappedLogger = index_1.wrapLogger( | ||
var wrappedLogger = (0, index_1.wrapLogger)( | ||
logger, | ||
@@ -84,4 +88,4 @@ { operation: { id: 'operation1' } }, | ||
wrappedLogger.info('test1') | ||
chai_1.expect(result.info[0].meta).deep.eq({ operation_id: 'operation1' }) | ||
chai_1.expect(result.info[0].msg).eq('test1') | ||
;(0, chai_1.expect)(result.info[0].meta).deep.eq({ operation_id: 'operation1' }) | ||
;(0, chai_1.expect)(result.info[0].msg).eq('test1') | ||
}) | ||
@@ -93,3 +97,3 @@ }) | ||
result = _a.result | ||
var wrappedLogger = index_1.wrapLogger( | ||
var wrappedLogger = (0, index_1.wrapLogger)( | ||
logger, | ||
@@ -100,12 +104,14 @@ { operation: { id: 'operation1' } }, | ||
wrappedLogger.info('test', { snapshot: { id: 'snapshot1' } }) | ||
chai_1 | ||
.expect(result.info[0].meta) | ||
.deep.eq({ operation_id: 'operation1', snapshot_id: 'snapshot1' }) | ||
;(0, chai_1.expect)(result.info[0].meta).deep.eq({ | ||
operation_id: 'operation1', | ||
snapshot_id: 'snapshot1' | ||
}) | ||
wrappedLogger.info('test2', { service: { name: 'service1' } }) | ||
chai_1 | ||
.expect(result.info[1].meta) | ||
.deep.eq({ operation_id: 'operation1', service_name: 'service1' }) | ||
var wrappedLogger2 = index_1.wrapLogger(wrappedLogger, { snapshot: { id: 'snapshot2' } }) | ||
;(0, chai_1.expect)(result.info[1].meta).deep.eq({ | ||
operation_id: 'operation1', | ||
service_name: 'service1' | ||
}) | ||
var wrappedLogger2 = (0, index_1.wrapLogger)(wrappedLogger, { snapshot: { id: 'snapshot2' } }) | ||
wrappedLogger2.info('test', { service: { name: 'service2' } }) | ||
chai_1.expect(result.info[2].meta).deep.eq({ | ||
;(0, chai_1.expect)(result.info[2].meta).deep.eq({ | ||
operation_id: 'operation1', | ||
@@ -115,5 +121,5 @@ snapshot_id: 'snapshot2', | ||
}) | ||
var wrappedLogger3 = index_1.wrapLogger(wrappedLogger, { snapshot: { id: 'snapshot3' } }) | ||
var wrappedLogger3 = (0, index_1.wrapLogger)(wrappedLogger, { snapshot: { id: 'snapshot3' } }) | ||
wrappedLogger3.info('test', { service: { name: 'service3' } }) | ||
chai_1.expect(result.info[3].meta).deep.eq({ | ||
;(0, chai_1.expect)(result.info[3].meta).deep.eq({ | ||
operation_id: 'operation1', | ||
@@ -129,7 +135,7 @@ snapshot_id: 'snapshot3', | ||
result = _a.result | ||
var wrappedLogger = index_1.wrapLogger(logger, { operation: { id: 'operation1' } }) | ||
var wrappedLogger = (0, index_1.wrapLogger)(logger, { operation: { id: 'operation1' } }) | ||
var error = new Error('error') | ||
wrappedLogger.info(error) | ||
chai_1.expect(result.info[0].msg).eq(error.message) | ||
chai_1.expect(result.info[0].meta).deep.eq({ | ||
;(0, chai_1.expect)(result.info[0].msg).eq(error.message) | ||
;(0, chai_1.expect)(result.info[0].meta).deep.eq({ | ||
operation: { id: 'operation1' }, | ||
@@ -139,3 +145,4 @@ error: { | ||
callstack: error.stack, | ||
name: 'Error' | ||
name: 'Error', | ||
raw: (0, error_1.getRaw)(error) | ||
} | ||
@@ -148,7 +155,7 @@ }) | ||
result = _a.result | ||
var wrappedLogger = index_1.wrapLogger(logger, { operation: { id: 'operation1' } }) | ||
var wrappedLogger = (0, index_1.wrapLogger)(logger, { operation: { id: 'operation1' } }) | ||
var error = new Error('error') | ||
wrappedLogger.info('test', error) | ||
chai_1.expect(result.info[0].msg).eq('test') | ||
chai_1.expect(result.info[0].meta).deep.eq({ | ||
;(0, chai_1.expect)(result.info[0].msg).eq('test') | ||
;(0, chai_1.expect)(result.info[0].meta).deep.eq({ | ||
operation: { id: 'operation1' }, | ||
@@ -158,3 +165,4 @@ error: { | ||
callstack: error.stack, | ||
name: 'Error' | ||
name: 'Error', | ||
raw: (0, error_1.getRaw)(error) | ||
} | ||
@@ -167,8 +175,8 @@ }) | ||
result = _a.result | ||
var wrappedLogger = index_1.wrapLogger(logger, { operation: { id: 'operation1' } }) | ||
var wrappedLogger = (0, index_1.wrapLogger)(logger, { operation: { id: 'operation1' } }) | ||
var error1 = new Error('error_1') | ||
var error2 = new Error('error_2') | ||
wrappedLogger.info(error1, error2) | ||
chai_1.expect(result.info[0].msg).eq(error1.message) | ||
chai_1.expect(result.info[0].meta).deep.eq({ | ||
;(0, chai_1.expect)(result.info[0].msg).eq(error1.message) | ||
;(0, chai_1.expect)(result.info[0].meta).deep.eq({ | ||
operation: { id: 'operation1' }, | ||
@@ -178,3 +186,4 @@ error: { | ||
callstack: error1.stack, | ||
name: 'Error' | ||
name: 'Error', | ||
raw: (0, error_1.getRaw)(error1) | ||
} | ||
@@ -189,3 +198,3 @@ }) | ||
result = _a.result | ||
var wrappedLogger = index_1.wrapLogger( | ||
var wrappedLogger = (0, index_1.wrapLogger)( | ||
logger, | ||
@@ -197,4 +206,4 @@ { operation: { id: 'operation1' } }, | ||
wrappedLogger.info(error) | ||
chai_1.expect(result.info[0].msg).eq(error.message) | ||
chai_1.expect(result.info[0].meta).deep.eq({ | ||
;(0, chai_1.expect)(result.info[0].msg).eq(error.message) | ||
;(0, chai_1.expect)(result.info[0].meta).deep.eq({ | ||
operation_id: 'operation1', | ||
@@ -204,3 +213,4 @@ error: { | ||
callstack: error.stack, | ||
name: 'Error' | ||
name: 'Error', | ||
raw: (0, error_1.getRaw)(error) | ||
} | ||
@@ -213,3 +223,3 @@ }) | ||
result = _a.result | ||
var wrappedLogger = index_1.wrapLogger( | ||
var wrappedLogger = (0, index_1.wrapLogger)( | ||
logger, | ||
@@ -221,4 +231,4 @@ { operation: { id: 'operation1' } }, | ||
wrappedLogger.info('test', error) | ||
chai_1.expect(result.info[0].msg).eq('test') | ||
chai_1.expect(result.info[0].meta).deep.eq({ | ||
;(0, chai_1.expect)(result.info[0].msg).eq('test') | ||
;(0, chai_1.expect)(result.info[0].meta).deep.eq({ | ||
operation_id: 'operation1', | ||
@@ -228,3 +238,4 @@ error: { | ||
callstack: error.stack, | ||
name: 'Error' | ||
name: 'Error', | ||
raw: (0, error_1.getRaw)(error) | ||
} | ||
@@ -237,3 +248,3 @@ }) | ||
result = _a.result | ||
var wrappedLogger = index_1.wrapLogger( | ||
var wrappedLogger = (0, index_1.wrapLogger)( | ||
logger, | ||
@@ -246,4 +257,4 @@ { operation: { id: 'operation1' } }, | ||
wrappedLogger.info(error1, error2) | ||
chai_1.expect(result.info[0].msg).eq(error1.message) | ||
chai_1.expect(result.info[0].meta).deep.eq({ | ||
;(0, chai_1.expect)(result.info[0].msg).eq(error1.message) | ||
;(0, chai_1.expect)(result.info[0].meta).deep.eq({ | ||
operation_id: 'operation1', | ||
@@ -253,3 +264,4 @@ error: { | ||
callstack: error1.stack, | ||
name: 'Error' | ||
name: 'Error', | ||
raw: (0, error_1.getRaw)(error1) | ||
} | ||
@@ -259,3 +271,14 @@ }) | ||
}) | ||
describe('should properly handle circular dependencies', function() { | ||
it('circular error thrown - error serialized', function() { | ||
var _a = makeLoggerStub(), | ||
logger = _a.logger, | ||
result = _a.result | ||
var error = new Error('error') | ||
error.cicleRef = error | ||
logger.error(error, error) | ||
;(0, chai_1.expect)(result.error[0].meta.message).eq(error.message) | ||
}) | ||
}) | ||
}) | ||
//# sourceMappingURL=wrap.spec.js.map |
{ | ||
"name": "loggerism", | ||
"version": "2.3.10", | ||
"version": "2.3.11", | ||
"description": "Yet another logger abstraction", | ||
@@ -25,3 +25,4 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"winston": "^3.1.0" | ||
"serialize-error": "^5.0.0", | ||
"winston": "^3.9.0" | ||
}, | ||
@@ -31,3 +32,3 @@ "devDependencies": { | ||
"@types/mocha": "^5.2.5", | ||
"@types/node": "^10.12.18", | ||
"@types/node": "^18.16.0", | ||
"chai": "^4.2.0", | ||
@@ -38,6 +39,6 @@ "mocha": "^5.2.0", | ||
"rimraf": "^2.6.3", | ||
"ts-node": "^7.0.1", | ||
"tslint": "^5.12.1", | ||
"tslint-config-prettier": "^1.17.0", | ||
"typescript": "^3.2.4" | ||
"ts-node": "^10.9.1", | ||
"tslint": "^6.1.3", | ||
"tslint-config-prettier": "^1.18.0", | ||
"typescript": "^5.0.4" | ||
}, | ||
@@ -44,0 +45,0 @@ "files": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
32900
523
2
+ Addedserialize-error@^5.0.0
+ Addedserialize-error@5.0.0(transitive)
+ Addedtype-fest@0.8.1(transitive)
Updatedwinston@^3.9.0