@leancodepl/logger 9.7.3 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,30 @@
3
3
  All notable changes to this project will be documented in this file. See
4
4
  [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [10.0.0](https://github.com/leancodepl/js_corelibrary/compare/v9.7.4...v10.0.0) (2026-02-11)
7
+
8
+ ### Bug Fixes
9
+
10
+ - exclude external packages from build output
11
+ ([4c2be7a](https://github.com/leancodepl/js_corelibrary/commit/4c2be7ac64eb6ed5603ba61b9aeef75a454dffb3))
12
+
13
+ # Change Log
14
+
15
+ All notable changes to this project will be documented in this file. See
16
+ [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
17
+
18
+ ## [9.7.4](https://github.com/leancodepl/js_corelibrary/compare/v9.7.3...v9.7.4) (2026-02-10)
19
+
20
+ ### Bug Fixes
21
+
22
+ - logger message key
23
+ ([acf7415](https://github.com/leancodepl/js_corelibrary/commit/acf74155e6312cf7374ba936cdcc57fc81dc68e3))
24
+
25
+ # Change Log
26
+
27
+ All notable changes to this project will be documented in this file. See
28
+ [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
29
+
6
30
  ## [9.7.3](https://github.com/leancodepl/js_corelibrary/compare/v9.7.2...v9.7.3) (2026-02-10)
7
31
 
8
32
  ### Bug Fixes
package/README.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  A lightweight, type-safe logger with middleware support and contextual messages.
4
4
 
5
+ **Entry points:**
6
+
7
+ - **`@leancodepl/logger`** – Core API below (custom handlers, context, middleware).
8
+ - **`@leancodepl/logger/cli`** – Colored console preset with log levels: `createCliLogger`, `LogLevel`, `allLogLevels`.
9
+ - **`@leancodepl/logger/json`** – JSON lines to stdout: `createJsonLogger` with the same level options as CLI.
10
+ - **`@leancodepl/logger/nest`** – NestJS adapter: `createNestJsonLogger()` implementing `LoggerService` with JSON output.
11
+
5
12
  ## Creating a Logger
6
13
 
7
14
  ```typescript
@@ -150,15 +157,11 @@ logger2.info("test") // "[INFO] test"
150
157
 
151
158
  ---
152
159
 
153
- # CLI Logger (from loggers package)
154
-
155
- Pre-built CLI logger using `@leancodepl/logger`.
160
+ ## CLI preset (`@leancodepl/logger/cli`)
156
161
 
157
- ## CLI Logger
162
+ Colored console logger with log levels for CLI applications.
158
163
 
159
- A colored console logger with log levels for CLI applications.
160
-
161
- ### Basic Usage
164
+ ### Basic usage
162
165
 
163
166
  ```typescript
164
167
  import { createCliLogger } from "@leancodepl/logger/cli"
@@ -173,7 +176,7 @@ logger.debug("Debug information")
173
176
  logger.verbose("Verbose output")
174
177
  ```
175
178
 
176
- ### Log Levels
179
+ ### Log levels
177
180
 
178
181
  Control which messages are shown by setting `enabledLogLevels` (array of levels to include):
179
182
 
@@ -196,7 +199,7 @@ Available log levels (from least to most verbose):
196
199
  - `LogLevel.Verbose` (4) - All above plus verbose
197
200
  - `LogLevel.Debug` (5) - Everything
198
201
 
199
- ### Adding Context
202
+ ### Adding context
200
203
 
201
204
  Use `withContext` to add contextual information:
202
205
 
@@ -207,7 +210,7 @@ const requestLogger = logger.withContext({ requestId: "req-123" })
207
210
  requestLogger.info(({ requestId }) => `Processing request ${requestId}`)
208
211
  ```
209
212
 
210
- ### Adding Middleware
213
+ ### Adding middleware
211
214
 
212
215
  Use `withMiddleware` to customize logging behavior:
213
216
 
@@ -222,3 +225,37 @@ const timedLogger = logger.withMiddleware({
222
225
  },
223
226
  })
224
227
  ```
228
+
229
+ ---
230
+
231
+ ## JSON preset (`@leancodepl/logger/json`)
232
+
233
+ Logger that writes one JSON object per line to stdout (level, timestamp, msg, optional context). Same log levels and `enabledLogLevels` option as the CLI preset.
234
+
235
+ ```typescript
236
+ import { createJsonLogger, allLogLevels, LogLevel } from "@leancodepl/logger/json"
237
+
238
+ const logger = createJsonLogger()
239
+ logger.info("Request completed") // {"level":"info","timestamp":"...","msg":"Request completed"}
240
+
241
+ const quiet = createJsonLogger({ enabledLogLevels: [LogLevel.Error, LogLevel.Warn] })
242
+ const verbose = createJsonLogger({ enabledLogLevels: allLogLevels })
243
+ ```
244
+
245
+ Supports `withContext` and `withMiddleware` like the base logger.
246
+
247
+ ---
248
+
249
+ ## Nest preset (`@leancodepl/logger/nest`)
250
+
251
+ NestJS `LoggerService` implementation that outputs JSON (same shape as the JSON preset). Use as a drop-in logger in Nest apps.
252
+
253
+ ```typescript
254
+ import { createNestJsonLogger, type LoggerService } from "@leancodepl/logger/nest"
255
+
256
+ const logger: LoggerService = createNestJsonLogger()
257
+ logger.log("Application started")
258
+ logger.error("Something went wrong", "MyService")
259
+ ```
260
+
261
+ If the last argument is a string, it is used as the `context` field in the JSON output (same behavior as Nest’s built-in logger).
package/dist/json.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./logger-CSPbXuiG.cjs"),s=require("./logLevels-B68KoC22.cjs");function c(e,r){return r.map(t=>o.isContextualMessage(t)?t(e):t)}function u(e){return e instanceof Error?{message:e.message,stack:e.stack}:e}function f(e){return typeof e=="object"&&e!==null?JSON.stringify(e):String(e)}function L(e,r){const t=s.logLevelToLabel[e];return(n,...g)=>{if(!s.isLogLevelEnabled(e,r))return;const a=c(n,g).map(l=>f(u(l))).join(" "),i={level:t,timestamp:new Date().toISOString(),msg:a,...Object.keys(n).length>0?{context:n}:{}};process.stdout.write(JSON.stringify(i)+`
2
- `)}}function m({enabledLogLevels:e=s.defaultEnabledLogLevels}={}){return o.createLogger({...s.allLogLevels.reduce((r,t)=>{const n=s.logLevelToLabel[t];return r[n]=L(t,e),r},{})})}exports.createJsonLogger=m;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./logger-CSPbXuiG.cjs"),s=require("./logLevels-B68KoC22.cjs");function c(e,r){return r.map(t=>o.isContextualMessage(t)?t(e):t)}function u(e){return e instanceof Error?{message:e.message,stack:e.stack}:e}function f(e){return typeof e=="object"&&e!==null?JSON.stringify(e):String(e)}function L(e,r){const t=s.logLevelToLabel[e];return(n,...a)=>{if(!s.isLogLevelEnabled(e,r))return;const g=c(n,a).map(l=>f(u(l))).join(" "),i={level:t,timestamp:new Date().toISOString(),message:g,...Object.keys(n).length>0?{context:n}:{}};process.stdout.write(JSON.stringify(i)+`
2
+ `)}}function p({enabledLogLevels:e=s.defaultEnabledLogLevels}={}){return o.createLogger({...s.allLogLevels.reduce((r,t)=>{const n=s.logLevelToLabel[t];return r[n]=L(t,e),r},{})})}exports.createJsonLogger=p;
package/dist/json.js CHANGED
@@ -17,7 +17,7 @@ function b(e, s) {
17
17
  const a = p(r, o).map((g) => d(L(g))).join(" "), i = {
18
18
  level: t,
19
19
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
20
- msg: a,
20
+ message: a,
21
21
  ...Object.keys(r).length > 0 ? { context: r } : {}
22
22
  };
23
23
  process.stdout.write(JSON.stringify(i) + `
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leancodepl/logger",
3
- "version": "9.7.3",
3
+ "version": "10.0.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",