🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@contember/logger

Package Overview
Dependencies
Maintainers
5
Versions
138
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@contember/logger - npm Package Compare versions

Comparing version

to
1.4.0-alpha.3

5

dist/src/impl.d.ts

@@ -1,2 +0,2 @@

import { Logger, LoggerAttributes, LoggerChildOptions, LoggerHandler, LoggerOptions } from './types';
import { Logger, LoggerAttributes, LoggerChildOptions, LoggerHandler, LoggerOptions, LogLevelName } from './types';
export declare const createLogger: (handler: LoggerHandler, attributes?: LoggerAttributes, options?: LoggerOptions) => Logger;

@@ -20,5 +20,6 @@ export declare class LoggerImpl implements Logger {

debug(messageOrError: unknown, attributes?: LoggerAttributes): void;
log(levelName: LogLevelName, messageOrError: unknown, attributes?: LoggerAttributes): void;
child(attributes?: LoggerAttributes, options?: Partial<LoggerChildOptions>): Logger;
scope<T>(cb: (logger: Logger) => Promise<T> | T, attributes?: LoggerAttributes, options?: Partial<LoggerChildOptions>): Promise<T>;
private log;
private doLog;
addHandler(handler: LoggerHandler): void;

@@ -25,0 +26,0 @@ close(): void;

16

dist/src/impl.js

@@ -26,16 +26,20 @@ "use strict";

crit(messageOrError, attributes) {
this.minLevelValue <= levels_1.LogLevels.crit.value && this.log(levels_1.LogLevels.crit, messageOrError, attributes);
this.minLevelValue <= levels_1.LogLevels.crit.value && this.doLog(levels_1.LogLevels.crit, messageOrError, attributes);
}
error(messageOrError, attributes) {
this.minLevelValue <= levels_1.LogLevels.error.value && this.log(levels_1.LogLevels.error, messageOrError, attributes);
this.minLevelValue <= levels_1.LogLevels.error.value && this.doLog(levels_1.LogLevels.error, messageOrError, attributes);
}
warn(messageOrError, attributes) {
this.minLevelValue <= levels_1.LogLevels.warn.value && this.log(levels_1.LogLevels.warn, messageOrError, attributes);
this.minLevelValue <= levels_1.LogLevels.warn.value && this.doLog(levels_1.LogLevels.warn, messageOrError, attributes);
}
info(messageOrError, attributes) {
this.minLevelValue <= levels_1.LogLevels.info.value && this.log(levels_1.LogLevels.info, messageOrError, attributes);
this.minLevelValue <= levels_1.LogLevels.info.value && this.doLog(levels_1.LogLevels.info, messageOrError, attributes);
}
debug(messageOrError, attributes) {
this.minLevelValue <= levels_1.LogLevels.debug.value && this.log(levels_1.LogLevels.debug, messageOrError, attributes);
this.minLevelValue <= levels_1.LogLevels.debug.value && this.doLog(levels_1.LogLevels.debug, messageOrError, attributes);
}
log(levelName, messageOrError, attributes) {
const level = levels_1.LogLevels[levelName];
this.minLevelValue <= level.value && this.doLog(level, messageOrError, attributes);
}
child(attributes = {}, options = {}) {

@@ -54,3 +58,3 @@ const newHandler = options.handler ? options.handler(this.handler, this.options) : this.handler;

}
log(level, errorOrMessage, { error: errorAttr, message: messageAttr, ...attributes } = {}) {
doLog(level, errorOrMessage, { error: errorAttr, message: messageAttr, ...attributes } = {}) {
var _a;

@@ -57,0 +61,0 @@ const error = typeof errorOrMessage !== 'string' ? errorOrMessage : errorAttr;

@@ -22,2 +22,5 @@ "use strict";

}
log(level, a, b, c) {
(0, exports.getLogger)().log(level, a, b);
}
child(attributes, options) {

@@ -24,0 +27,0 @@ return (0, exports.getLogger)().child(attributes, options);

@@ -10,2 +10,3 @@ import { FingerCrossedLoggerHandlerOptions } from './handlers/FingerCrossedLoggerHandler';

debug: LogFn;
log(level: LogLevelName, messageOrError: unknown, attributes?: LoggerAttributes): void;
child(attributes?: LoggerAttributes, options?: Partial<LoggerChildOptions>): Logger;

@@ -12,0 +13,0 @@ scope<T>(cb: (logger: Logger) => Promise<T> | T, attributes?: LoggerAttributes, options?: Partial<LoggerChildOptions>): Promise<T>;

{
"name": "@contember/logger",
"version": "1.4.0-alpha.2",
"version": "1.4.0-alpha.3",
"license": "Apache-2.0",

@@ -15,3 +15,3 @@ "main": "dist/src/index.js",

"devDependencies": {
"@types/node": "^18"
"@types/node": "^20.9.0"
},

@@ -18,0 +18,0 @@ "dependencies": {

@@ -9,3 +9,3 @@ import {

LoggerOptions,
LogLevel,
LogLevel, LogLevelName,
} from './types'

@@ -53,21 +53,26 @@ import { LogLevels } from './levels'

public crit(messageOrError: unknown, attributes?: LoggerAttributes) {
this.minLevelValue <= LogLevels.crit.value && this.log(LogLevels.crit, messageOrError, attributes)
this.minLevelValue <= LogLevels.crit.value && this.doLog(LogLevels.crit, messageOrError, attributes)
}
public error(messageOrError: unknown, attributes?: LoggerAttributes) {
this.minLevelValue <= LogLevels.error.value && this.log(LogLevels.error, messageOrError, attributes)
this.minLevelValue <= LogLevels.error.value && this.doLog(LogLevels.error, messageOrError, attributes)
}
public warn(messageOrError: unknown, attributes?: LoggerAttributes) {
this.minLevelValue <= LogLevels.warn.value && this.log(LogLevels.warn, messageOrError, attributes)
this.minLevelValue <= LogLevels.warn.value && this.doLog(LogLevels.warn, messageOrError, attributes)
}
public info(messageOrError: unknown, attributes?: LoggerAttributes) {
this.minLevelValue <= LogLevels.info.value && this.log(LogLevels.info, messageOrError, attributes)
this.minLevelValue <= LogLevels.info.value && this.doLog(LogLevels.info, messageOrError, attributes)
}
public debug(messageOrError: unknown, attributes?: LoggerAttributes) {
this.minLevelValue <= LogLevels.debug.value && this.log(LogLevels.debug, messageOrError, attributes)
this.minLevelValue <= LogLevels.debug.value && this.doLog(LogLevels.debug, messageOrError, attributes)
}
public log(levelName: LogLevelName, messageOrError: unknown, attributes?: LoggerAttributes) {
const level = LogLevels[levelName]
this.minLevelValue <= level.value && this.doLog(level, messageOrError, attributes)
}
public child(attributes: LoggerAttributes = {}, options: Partial<LoggerChildOptions> = {}): Logger {

@@ -87,3 +92,3 @@ const newHandler = options.handler ? options.handler(this.handler, this.options) : this.handler

private log(level: LogLevel, errorOrMessage: unknown, { error: errorAttr, message: messageAttr, ...attributes }: LoggerAttributes = {}) {
private doLog(level: LogLevel, errorOrMessage: unknown, { error: errorAttr, message: messageAttr, ...attributes }: LoggerAttributes = {}) {
const error: unknown | undefined = typeof errorOrMessage !== 'string' ? errorOrMessage : errorAttr

@@ -90,0 +95,0 @@ const errorMessage = typeof error === 'object' && error !== null && typeof (error as any).message === 'string'

@@ -27,2 +27,6 @@ import { Logger, LoggerAttributes, LoggerHandler, LoggerOptions } from './types'

log(level: any, a: any, b?: any, c?: any) {
getLogger().log(level, a, b)
}
child(attributes?: LoggerAttributes, options?: Partial<LoggerOptions>): Logger {

@@ -29,0 +33,0 @@ return getLogger().child(attributes, options)

@@ -14,2 +14,4 @@ import { FingerCrossedLoggerHandlerOptions } from './handlers/FingerCrossedLoggerHandler'

log(level: LogLevelName, messageOrError: unknown, attributes?: LoggerAttributes): void
child(attributes?: LoggerAttributes, options?: Partial<LoggerChildOptions>): Logger

@@ -16,0 +18,0 @@ scope<T>(cb: (logger: Logger) => Promise<T> | T, attributes?: LoggerAttributes, options?: Partial<LoggerChildOptions>): Promise<T>

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