@rarible/logger
Advanced tools
Comparing version 0.10.0-alpha.45 to 0.10.0-alpha.46
@@ -34,13 +34,13 @@ import { LogLevel } from "./domain.js"; | ||
constructor(config: LoggerConfig<C>); | ||
getContext: () => Promise<C & Partial<C>>; | ||
raw: (data: LoggerRequiredRawData) => Promise<void>; | ||
data: (level: LogLevel, data: LoggerRawData, args?: any[]) => Promise<void>; | ||
message: (level: LogLevel, ...params: any[]) => Promise<void>; | ||
trace: (...params: any[]) => void; | ||
warn: (...params: any[]) => void; | ||
error: (...params: any[]) => void; | ||
info: (...params: any[]) => void; | ||
debug: (...params: any[]) => void; | ||
extend: <NewC extends LoggerContextData>(nextContext: NewC) => Logger<NewC & C>; | ||
updateContext: (nextContext: Partial<C>) => void; | ||
getContext(): Promise<C & Partial<C>>; | ||
raw(data: LoggerRequiredRawData): Promise<void>; | ||
data(level: LogLevel, data: LoggerRawData, args?: any[]): Promise<void>; | ||
message(level: LogLevel, ...params: any[]): Promise<void>; | ||
trace(...params: any[]): void; | ||
warn(...params: any[]): void; | ||
error(...params: any[]): void; | ||
info(...params: any[]): void; | ||
debug(...params: any[]): void; | ||
extend<NewC extends LoggerContextData>(nextContext: NewC): Logger<NewC & C>; | ||
updateContext(nextContext: Partial<C>): void; | ||
} |
@@ -16,6 +16,25 @@ "use strict"; | ||
this.contextOverrides = {}; | ||
this.getContext = () => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
return (Object.assign(Object.assign({}, (yield this.config.getContext())), this.contextOverrides)); | ||
this.maxByteSize = (_a = this.config.maxByteSize) !== null && _a !== void 0 ? _a : 1024 * 10; | ||
this.indent = (_b = this.config.indent) !== null && _b !== void 0 ? _b : 2; | ||
const middlewares = (_c = this.config.middlewares) !== null && _c !== void 0 ? _c : []; | ||
this.reducedMiddleware = (0, combine_js_1.combineMiddlewares)(...middlewares); | ||
this.getContext = this.getContext.bind(this); | ||
this.raw = this.raw.bind(this); | ||
this.data = this.data.bind(this); | ||
this.message = this.message.bind(this); | ||
this.trace = this.trace.bind(this); | ||
this.warn = this.warn.bind(this); | ||
this.error = this.error.bind(this); | ||
this.info = this.info.bind(this); | ||
this.debug = this.debug.bind(this); | ||
this.extend = this.extend.bind(this); | ||
this.updateContext = this.updateContext.bind(this); | ||
} | ||
getContext() { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
return Object.assign(Object.assign({}, (yield this.config.getContext())), this.contextOverrides); | ||
}); | ||
this.raw = (data) => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
} | ||
raw(data) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
try { | ||
@@ -31,37 +50,39 @@ const context = yield this.getContext(); | ||
}); | ||
this.data = (level, data, args = []) => this.raw(Object.assign({ level, message: args }, data)); | ||
this.message = (level, ...params) => this.raw({ | ||
} | ||
data(level, data, args = []) { | ||
return this.raw(Object.assign({ level, message: args }, data)); | ||
} | ||
message(level, ...params) { | ||
return this.raw({ | ||
level, | ||
message: params, | ||
}); | ||
this.trace = (...params) => { | ||
this.message(domain_js_1.LogLevel.TRACE, ...params); | ||
}; | ||
this.warn = (...params) => { | ||
this.message(domain_js_1.LogLevel.WARN, ...params); | ||
}; | ||
this.error = (...params) => { | ||
this.message(domain_js_1.LogLevel.ERROR, ...params); | ||
}; | ||
this.info = (...params) => { | ||
this.message(domain_js_1.LogLevel.INFO, ...params); | ||
}; | ||
this.debug = (...params) => { | ||
this.message(domain_js_1.LogLevel.DEBUG, ...params); | ||
}; | ||
this.extend = (nextContext) => new Logger(Object.assign(Object.assign({}, this.config), { getContext: () => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
} | ||
trace(...params) { | ||
this.message(domain_js_1.LogLevel.TRACE, ...params); | ||
} | ||
warn(...params) { | ||
this.message(domain_js_1.LogLevel.WARN, ...params); | ||
} | ||
error(...params) { | ||
this.message(domain_js_1.LogLevel.ERROR, ...params); | ||
} | ||
info(...params) { | ||
this.message(domain_js_1.LogLevel.INFO, ...params); | ||
} | ||
debug(...params) { | ||
this.message(domain_js_1.LogLevel.DEBUG, ...params); | ||
} | ||
extend(nextContext) { | ||
return new Logger(Object.assign(Object.assign({}, this.config), { getContext: () => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
return (Object.assign(Object.assign({}, (yield this.getContext())), nextContext)); | ||
}) })); | ||
this.updateContext = (nextContext) => { | ||
this.contextOverrides = Object.assign(Object.assign({}, this.contextOverrides), nextContext); | ||
this.config.transports.forEach(x => { | ||
x.reset(); | ||
}); | ||
}; | ||
this.maxByteSize = (_a = this.config.maxByteSize) !== null && _a !== void 0 ? _a : 1024 * 10; | ||
this.indent = (_b = this.config.indent) !== null && _b !== void 0 ? _b : 2; | ||
const middlewares = (_c = this.config.middlewares) !== null && _c !== void 0 ? _c : []; | ||
this.reducedMiddleware = (0, combine_js_1.combineMiddlewares)(...middlewares); | ||
} | ||
updateContext(nextContext) { | ||
this.contextOverrides = Object.assign(Object.assign({}, this.contextOverrides), nextContext); | ||
this.config.transports.forEach(x => { | ||
x.reset(); | ||
}); | ||
} | ||
} | ||
exports.Logger = Logger; |
@@ -34,13 +34,13 @@ import { LogLevel } from "./domain.js"; | ||
constructor(config: LoggerConfig<C>); | ||
getContext: () => Promise<C & Partial<C>>; | ||
raw: (data: LoggerRequiredRawData) => Promise<void>; | ||
data: (level: LogLevel, data: LoggerRawData, args?: any[]) => Promise<void>; | ||
message: (level: LogLevel, ...params: any[]) => Promise<void>; | ||
trace: (...params: any[]) => void; | ||
warn: (...params: any[]) => void; | ||
error: (...params: any[]) => void; | ||
info: (...params: any[]) => void; | ||
debug: (...params: any[]) => void; | ||
extend: <NewC extends LoggerContextData>(nextContext: NewC) => Logger<NewC & C>; | ||
updateContext: (nextContext: Partial<C>) => void; | ||
getContext(): Promise<C & Partial<C>>; | ||
raw(data: LoggerRequiredRawData): Promise<void>; | ||
data(level: LogLevel, data: LoggerRawData, args?: any[]): Promise<void>; | ||
message(level: LogLevel, ...params: any[]): Promise<void>; | ||
trace(...params: any[]): void; | ||
warn(...params: any[]): void; | ||
error(...params: any[]): void; | ||
info(...params: any[]): void; | ||
debug(...params: any[]): void; | ||
extend<NewC extends LoggerContextData>(nextContext: NewC): Logger<NewC & C>; | ||
updateContext(nextContext: Partial<C>): void; | ||
} |
@@ -12,6 +12,25 @@ import { __awaiter } from "tslib"; | ||
this.contextOverrides = {}; | ||
this.getContext = () => __awaiter(this, void 0, void 0, function* () { | ||
return (Object.assign(Object.assign({}, (yield this.config.getContext())), this.contextOverrides)); | ||
this.maxByteSize = (_a = this.config.maxByteSize) !== null && _a !== void 0 ? _a : 1024 * 10; | ||
this.indent = (_b = this.config.indent) !== null && _b !== void 0 ? _b : 2; | ||
const middlewares = (_c = this.config.middlewares) !== null && _c !== void 0 ? _c : []; | ||
this.reducedMiddleware = combineMiddlewares(...middlewares); | ||
this.getContext = this.getContext.bind(this); | ||
this.raw = this.raw.bind(this); | ||
this.data = this.data.bind(this); | ||
this.message = this.message.bind(this); | ||
this.trace = this.trace.bind(this); | ||
this.warn = this.warn.bind(this); | ||
this.error = this.error.bind(this); | ||
this.info = this.info.bind(this); | ||
this.debug = this.debug.bind(this); | ||
this.extend = this.extend.bind(this); | ||
this.updateContext = this.updateContext.bind(this); | ||
} | ||
getContext() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return Object.assign(Object.assign({}, (yield this.config.getContext())), this.contextOverrides); | ||
}); | ||
this.raw = (data) => __awaiter(this, void 0, void 0, function* () { | ||
} | ||
raw(data) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
@@ -27,36 +46,38 @@ const context = yield this.getContext(); | ||
}); | ||
this.data = (level, data, args = []) => this.raw(Object.assign({ level, message: args }, data)); | ||
this.message = (level, ...params) => this.raw({ | ||
} | ||
data(level, data, args = []) { | ||
return this.raw(Object.assign({ level, message: args }, data)); | ||
} | ||
message(level, ...params) { | ||
return this.raw({ | ||
level, | ||
message: params, | ||
}); | ||
this.trace = (...params) => { | ||
this.message(LogLevel.TRACE, ...params); | ||
}; | ||
this.warn = (...params) => { | ||
this.message(LogLevel.WARN, ...params); | ||
}; | ||
this.error = (...params) => { | ||
this.message(LogLevel.ERROR, ...params); | ||
}; | ||
this.info = (...params) => { | ||
this.message(LogLevel.INFO, ...params); | ||
}; | ||
this.debug = (...params) => { | ||
this.message(LogLevel.DEBUG, ...params); | ||
}; | ||
this.extend = (nextContext) => new Logger(Object.assign(Object.assign({}, this.config), { getContext: () => __awaiter(this, void 0, void 0, function* () { | ||
} | ||
trace(...params) { | ||
this.message(LogLevel.TRACE, ...params); | ||
} | ||
warn(...params) { | ||
this.message(LogLevel.WARN, ...params); | ||
} | ||
error(...params) { | ||
this.message(LogLevel.ERROR, ...params); | ||
} | ||
info(...params) { | ||
this.message(LogLevel.INFO, ...params); | ||
} | ||
debug(...params) { | ||
this.message(LogLevel.DEBUG, ...params); | ||
} | ||
extend(nextContext) { | ||
return new Logger(Object.assign(Object.assign({}, this.config), { getContext: () => __awaiter(this, void 0, void 0, function* () { | ||
return (Object.assign(Object.assign({}, (yield this.getContext())), nextContext)); | ||
}) })); | ||
this.updateContext = (nextContext) => { | ||
this.contextOverrides = Object.assign(Object.assign({}, this.contextOverrides), nextContext); | ||
this.config.transports.forEach(x => { | ||
x.reset(); | ||
}); | ||
}; | ||
this.maxByteSize = (_a = this.config.maxByteSize) !== null && _a !== void 0 ? _a : 1024 * 10; | ||
this.indent = (_b = this.config.indent) !== null && _b !== void 0 ? _b : 2; | ||
const middlewares = (_c = this.config.middlewares) !== null && _c !== void 0 ? _c : []; | ||
this.reducedMiddleware = combineMiddlewares(...middlewares); | ||
} | ||
updateContext(nextContext) { | ||
this.contextOverrides = Object.assign(Object.assign({}, this.contextOverrides), nextContext); | ||
this.config.transports.forEach(x => { | ||
x.reset(); | ||
}); | ||
} | ||
} |
{ | ||
"name": "@rarible/logger", | ||
"version": "0.10.0-alpha.45", | ||
"version": "0.10.0-alpha.46", | ||
"description": "Logging utility for ts projects", | ||
@@ -50,3 +50,3 @@ "homepage": "https://github.com/rarible/ts-common", | ||
"dependencies": { | ||
"@rarible/utils": "^0.10.0-alpha.45", | ||
"@rarible/utils": "^0.10.0-alpha.46", | ||
"generic-type-guard": "^3.7.2", | ||
@@ -77,3 +77,3 @@ "json-stringify-safe": "^5.0.1", | ||
}, | ||
"gitHead": "0d38ec4c0f26b6065816428ca9c80727560526b1" | ||
"gitHead": "d53cf547a3d3e705a0dc510a9f30319173871037" | ||
} |
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
116190
1135