tsedio / logger

📄 A multi channel logger written in TypeScript.
https://logger.tsed.io
MIT License
64 stars 24 forks source link

refactor(jsonlayout): maintain layout even if data in logger context #253

Open Bugslive opened 4 months ago

Bugslive commented 4 months ago

Informations

Type  Status Migration
Refactor Ready No

Description

Example

Before:

without additional data in logger context: {"startTime":"2024-07-10T16:29:22.398Z","categoryName":"TSED","level":"INFO",..., "data":[]}

with additional data in logger context const context = new LogContext(); context.set("user", "romain"); {"user": romain", "startTime":"2024-07-10T16:29:22.398Z","categoryName":"TSED","level":"INFO",..., "data":[]}

After:

with additional data in logger context {"startTime":"2024-07-10T16:29:22.398Z","categoryName":"TSED","level":"INFO", "user": romain", ..., "data":[]}

Todos

Bugslive commented 2 months ago

Hello @Romakita. Do you think this request could be merged ? We would appreciate to have this minor evolution.

Romakita commented 2 months ago

Hello @Bugslive But changing the order assignment will allow data to override level, categoryName and startTime fields.

So I can't accept the change right know

Bugslive commented 2 months ago

Hello @Romakita. I made an improvement to prevent startTime, level and categoryName to be overridden. I also had a corresponding test.