Comparing version 1.5.2 to 1.6.0
@@ -15,4 +15,5 @@ import type { ThreadGroupConfig } from '../streams'; | ||
set logger(logger: Logger); | ||
useLogger(logger: Logger, priority?: number): void; | ||
useLogger(logger: Logger, priority?: number): this; | ||
useTransform(transformFields: Required<BunyaminConfig<Logger>>['transformFields']): this; | ||
child(overrides?: UserFields): Bunyamin<Logger>; | ||
} |
@@ -103,2 +103,6 @@ (function (global, factory) { | ||
function flow(f, g) { | ||
return x => g(f(x)); | ||
} | ||
function isActionable(value) { | ||
@@ -203,4 +207,12 @@ return typeof value === 'function'; | ||
var _resolveFields = /*#__PURE__*/_classPrivateFieldLooseKey("resolveFields"); | ||
var _assertNotChild = /*#__PURE__*/_classPrivateFieldLooseKey("assertNotChild"); | ||
var _assertNotImmutable = /*#__PURE__*/_classPrivateFieldLooseKey("assertNotImmutable"); | ||
class Bunyamin { | ||
constructor(shared, _fields2) { | ||
Object.defineProperty(this, _assertNotImmutable, { | ||
value: _assertNotImmutable2 | ||
}); | ||
Object.defineProperty(this, _assertNotChild, { | ||
value: _assertNotChild2 | ||
}); | ||
Object.defineProperty(this, _resolveFields, { | ||
@@ -281,8 +293,4 @@ value: _resolveFields2 | ||
useLogger(logger, priority = 0) { | ||
if (_classPrivateFieldLooseBase(this, _shared)[_shared].immutable) { | ||
throw new Error('Cannot change a logger of an immutable instance'); | ||
} | ||
if (_classPrivateFieldLooseBase(this, _fields)[_fields]) { | ||
throw new Error('Cannot change a logger of a child instance'); | ||
} | ||
_classPrivateFieldLooseBase(this, _assertNotImmutable)[_assertNotImmutable](); | ||
_classPrivateFieldLooseBase(this, _assertNotChild)[_assertNotChild]('useLogger'); | ||
const { | ||
@@ -303,3 +311,10 @@ stack | ||
} | ||
return this; | ||
} | ||
useTransform(transformFields) { | ||
_classPrivateFieldLooseBase(this, _assertNotImmutable)[_assertNotImmutable](); | ||
_classPrivateFieldLooseBase(this, _assertNotChild)[_assertNotChild]('useTransform'); | ||
_classPrivateFieldLooseBase(this, _shared)[_shared].transformFields = _classPrivateFieldLooseBase(this, _shared)[_shared].transformFields ? flow(_classPrivateFieldLooseBase(this, _shared)[_shared].transformFields, transformFields) : transformFields; | ||
return this; | ||
} | ||
child(overrides) { | ||
@@ -418,2 +433,12 @@ const childContext = _classPrivateFieldLooseBase(this, _mergeFields)[_mergeFields](_classPrivateFieldLooseBase(this, _fields)[_fields], _classPrivateFieldLooseBase(this, _transformContext)[_transformContext](overrides)); | ||
} | ||
function _assertNotChild2(methodName) { | ||
if (_classPrivateFieldLooseBase(this, _fields)[_fields]) { | ||
throw new Error(`Method Bunyamin#${methodName} is not available for child instances`); | ||
} | ||
} | ||
function _assertNotImmutable2() { | ||
if (_classPrivateFieldLooseBase(this, _shared)[_shared].immutable) { | ||
throw new Error('Cannot change a logger of an immutable instance'); | ||
} | ||
} | ||
@@ -435,3 +460,2 @@ const noop = () => {}; | ||
let _Symbol$iterator$1; | ||
var _bunyamin = /*#__PURE__*/_classPrivateFieldLooseKey("bunyamin"); | ||
@@ -441,3 +465,2 @@ var _debugMode = /*#__PURE__*/_classPrivateFieldLooseKey("debugMode"); | ||
var _logAddition = /*#__PURE__*/_classPrivateFieldLooseKey("logAddition"); | ||
_Symbol$iterator$1 = Symbol.iterator; | ||
class ThreadGroups { | ||
@@ -474,3 +497,3 @@ constructor(bunyamin) { | ||
} | ||
[_Symbol$iterator$1]() { | ||
[Symbol.iterator]() { | ||
return _classPrivateFieldLooseBase(this, _groups)[_groups].values(); | ||
@@ -1029,6 +1052,4 @@ } | ||
let _Symbol$iterator; | ||
var _children = /*#__PURE__*/_classPrivateFieldLooseKey("children"); | ||
var _map = /*#__PURE__*/_classPrivateFieldLooseKey("map"); | ||
_Symbol$iterator = Symbol.iterator; | ||
class ArrayTreeNode { | ||
@@ -1052,3 +1073,3 @@ constructor(value) { | ||
} | ||
[_Symbol$iterator]() { | ||
[Symbol.iterator]() { | ||
return _classPrivateFieldLooseBase(this, _children)[_children][Symbol.iterator](); | ||
@@ -1055,0 +1076,0 @@ } |
@@ -0,1 +1,2 @@ | ||
export * from './flow'; | ||
export * from './isActionable'; | ||
@@ -2,0 +3,0 @@ export * from './isError'; |
import type { BunyaminConfig, BunyanLikeLogger } from './decorator'; | ||
import { Bunyamin } from './decorator'; | ||
export type * from './decorator'; | ||
export * from './decorator/types'; | ||
export type { Bunyamin } from './decorator'; | ||
export declare function wrapLogger<Logger extends BunyanLikeLogger>(options: BunyaminConfig<Logger>): Bunyamin<Logger>; | ||
export declare function wrapLogger<Logger extends BunyanLikeLogger>(logger: Logger, options?: Omit<BunyaminConfig<Logger>, 'logger'>): Bunyamin<Logger>; |
{ | ||
"name": "bunyamin", | ||
"version": "1.5.2", | ||
"version": "1.6.0", | ||
"description": "Bunyan-based logger for Node.js supporting Trace Event format", | ||
@@ -90,4 +90,4 @@ "license": "MIT", | ||
"peerDependencies": { | ||
"bunyan": "^1.8.15 || ^2.0.0", | ||
"@types/bunyan": "^1.8.8" | ||
"@types/bunyan": "^1.8.8", | ||
"bunyan": "^1.8.15 || ^2.0.0" | ||
}, | ||
@@ -94,0 +94,0 @@ "peerDependenciesMeta": { |
@@ -5,3 +5,3 @@ import { deflateCategories, mergeCategories } from './categories'; | ||
import type { ThreadID } from '../types'; | ||
import { isActionable, isError, isObject, isPromiseLike } from '../utils'; | ||
import { flow, isActionable, isError, isObject, isPromiseLike } from '../utils'; | ||
import type { | ||
@@ -63,11 +63,6 @@ BunyaminLogMethod, | ||
useLogger(logger: Logger, priority = 0): void { | ||
if (this.#shared.immutable) { | ||
throw new Error('Cannot change a logger of an immutable instance'); | ||
} | ||
useLogger(logger: Logger, priority = 0): this { | ||
this.#assertNotImmutable(); | ||
this.#assertNotChild('useLogger'); | ||
if (this.#fields) { | ||
throw new Error('Cannot change a logger of a child instance'); | ||
} | ||
const { stack } = isSelfDebug() ? new StackTraceError() : StackTraceError.empty(); | ||
@@ -90,4 +85,17 @@ const currentPriority = this.#shared.loggerPriority; | ||
} | ||
return this; | ||
} | ||
useTransform(transformFields: Required<BunyaminConfig<Logger>>['transformFields']): this { | ||
this.#assertNotImmutable(); | ||
this.#assertNotChild('useTransform'); | ||
this.#shared.transformFields = this.#shared.transformFields | ||
? flow(this.#shared.transformFields, transformFields) | ||
: transformFields; | ||
return this; | ||
} | ||
child(overrides?: UserFields): Bunyamin<Logger> { | ||
@@ -233,2 +241,14 @@ const childContext = this.#mergeFields(this.#fields, this.#transformContext(overrides)); | ||
} | ||
#assertNotChild(methodName: string): void { | ||
if (this.#fields) { | ||
throw new Error(`Method Bunyamin#${methodName} is not available for child instances`); | ||
} | ||
} | ||
#assertNotImmutable(): void { | ||
if (this.#shared.immutable) { | ||
throw new Error('Cannot change a logger of an immutable instance'); | ||
} | ||
} | ||
} | ||
@@ -235,0 +255,0 @@ |
@@ -0,1 +1,2 @@ | ||
export * from './flow'; | ||
export * from './isActionable'; | ||
@@ -2,0 +3,0 @@ export * from './isError'; |
import type { BunyaminConfig, BunyanLikeLogger } from './decorator'; | ||
import { Bunyamin } from './decorator'; | ||
export type * from './decorator'; | ||
export * from './decorator/types'; | ||
export type { Bunyamin } from './decorator'; | ||
@@ -6,0 +7,0 @@ export function wrapLogger<Logger extends BunyanLikeLogger>( |
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
368615
146
4484