From 02696c1fadc0e05c22ec6ff5c4784d454caa1f09 Mon Sep 17 00:00:00 2001 From: Yaroslav Serhieiev Date: Wed, 3 Jul 2024 12:12:19 +0300 Subject: [PATCH] fix: allow overriding level in log.*.complete --- src/decorator/Bunyamin.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/decorator/Bunyamin.ts b/src/decorator/Bunyamin.ts index 1c7ed98..16a7e5d 100644 --- a/src/decorator/Bunyamin.ts +++ b/src/decorator/Bunyamin.ts @@ -160,9 +160,16 @@ export class Bunyamin { const endContext = { ...this.#transformContext(customContext), ph: 'E', - tid: fields.tid, } as ResolvedFields; + if (fields.tid !== undefined) { + endContext.tid = fields.tid; + } + + if (fields.level !== undefined) { + endContext.level = fields.level; + } + this.#endInternal(level, endContext, []); }; @@ -266,6 +273,15 @@ type ResolvedFields = UserFields & { cat?: string; ph?: 'B' | 'E'; tid?: ThreadID; + /** + * 10 - trace + * 20 - debug + * 30 - info + * 40 - warn + * 50 - error + * 60 - fatal + */ + level?: number; }; type SharedBunyaminConfig = BunyaminConfig & {