@browserspy/common
Advanced tools
Comparing version 0.4.3 to 0.4.4
@@ -5,3 +5,3 @@ /// <reference types="bunyan" /> | ||
bunyan: typeof bunyan; | ||
logger: (name: string, level: string | number) => bunyan; | ||
logger: (name: string, level: string | number) => import("./lib/logger").ILogger; | ||
router: (parent: import("express-serve-static-core").Express, dir: string, logger?: bunyan | undefined) => void; | ||
@@ -8,0 +8,0 @@ }; |
import bunyan from 'bunyan'; | ||
export { bunyan, }; | ||
declare const _default: (name: string, level: string | number) => bunyan; | ||
export interface IKeyValue<V> { | ||
[key: string]: V; | ||
} | ||
export interface ILoggerFn { | ||
(msg: string, obj: IKeyValue<any>, ...args: any[]): void; | ||
} | ||
export interface ILogger { | ||
fatal: ILoggerFn; | ||
error: ILoggerFn; | ||
warn: ILoggerFn; | ||
info: ILoggerFn; | ||
debug: ILoggerFn; | ||
trace: ILoggerFn; | ||
} | ||
declare const _default: (name: string, level: string | number) => ILogger; | ||
export default _default; | ||
//# sourceMappingURL=logger.d.ts.map |
@@ -16,2 +16,12 @@ "use strict"; | ||
]; | ||
var factory = function (logger, level) { | ||
return function (msg, obj) { | ||
if (obj === void 0) { obj = {}; } | ||
var args = []; | ||
for (var _i = 2; _i < arguments.length; _i++) { | ||
args[_i - 2] = arguments[_i]; | ||
} | ||
logger[level].apply(logger, [obj, msg].concat(args)); | ||
}; | ||
}; | ||
exports.default = (function (name, level) { | ||
@@ -21,3 +31,3 @@ if (typeof level === 'string' && !allowedLevels.includes(level)) { | ||
} | ||
return bunyan_1.default.createLogger({ | ||
var logger = bunyan_1.default.createLogger({ | ||
name: name, | ||
@@ -27,3 +37,11 @@ level: level, | ||
}); | ||
return { | ||
fatal: factory(logger, 'fatal'), | ||
error: factory(logger, 'error'), | ||
warn: factory(logger, 'warn'), | ||
info: factory(logger, 'info'), | ||
debug: factory(logger, 'debug'), | ||
trace: factory(logger, 'trace'), | ||
}; | ||
}); | ||
//# sourceMappingURL=logger.js.map |
@@ -193,3 +193,3 @@ "use strict"; | ||
else { | ||
logger.info('Routes', routes.map(function (_a) { | ||
var loggedRoutes = routes.map(function (_a) { | ||
var url = _a.url, method = _a.method; | ||
@@ -200,3 +200,4 @@ return ({ | ||
}); | ||
})); | ||
}); | ||
logger.info(loggedRoutes, 'Routes'); | ||
} | ||
@@ -203,0 +204,0 @@ parent.use(app); |
{ | ||
"name": "@browserspy/common", | ||
"version": "0.4.3", | ||
"version": "0.4.4", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./index", |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
18868
294
0