@leancodepl/logger 9.7.2 → 9.7.3

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 ADDED
@@ -0,0 +1,25 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file. See
4
+ [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ ## [9.7.3](https://github.com/leancodepl/js_corelibrary/compare/v9.7.2...v9.7.3) (2026-02-10)
7
+
8
+ ### Bug Fixes
9
+
10
+ - logger test ([3260655](https://github.com/leancodepl/js_corelibrary/commit/3260655a6fc063e2fdf37551a8a6af046ef447bd))
11
+ - missing logger files
12
+ ([20227e7](https://github.com/leancodepl/js_corelibrary/commit/20227e768660f47befad4c130566024dbff0665b))
13
+
14
+ ### Features
15
+
16
+ - add empty logger package
17
+ ([97bb645](https://github.com/leancodepl/js_corelibrary/commit/97bb645d65fb3a7e44290e9b4278908e796e1170))
18
+ - add empty logger package
19
+ ([3387a75](https://github.com/leancodepl/js_corelibrary/commit/3387a750d48a48d9143a69658ed90d5bcf2eeb50))
20
+ - add json and nest loggers
21
+ ([e52d730](https://github.com/leancodepl/js_corelibrary/commit/e52d7301e72f01c8789f76682c7e465ea66f153b))
22
+ - allow unknown output in logger
23
+ ([d5f9107](https://github.com/leancodepl/js_corelibrary/commit/d5f91075b87a9fb41c85c1e6302f986ac8c7cfc0))
24
+ - implement logger
25
+ ([15ef6e4](https://github.com/leancodepl/js_corelibrary/commit/15ef6e43d8b825ea646964a956f3046c47de5767))
package/dist/cli.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("chalk"),l=require("./index.cjs");var u=(e=>(e[e.Error=0]="Error",e[e.Warn=1]="Warn",e[e.Success=2]="Success",e[e.Info=3]="Info",e[e.Verbose=4]="Verbose",e[e.Debug=5]="Debug",e))(u||{});const t=[0,1,2,3,4,5],g=[0,1,2,3],c={0:"error",1:"warn",2:"success",3:"info",4:"verbose",5:"debug"},b={0:a.red,1:a.yellow,2:a.green,3:a.blue,4:a.gray,5:a.magenta};function d(e,s){return s.includes(e)}function f(e,s){return s.map(r=>l.isContextualMessage(r)?r(e):r)}function k(e,s){return(r,...n)=>{if(d(e,s)){const o=f(r,n);switch(e){case 0:console.error(...o);break;case 1:console.warn(...o);break;case 2:console.log(...o);break;case 3:console.info(...o);break;case 4:console.log(...o);break;case 5:console.log(...o);break}}}}function M(e){return s=>(r,...n)=>{const o=b[e],i=c[e];s(r,o(`[${i.toUpperCase()}]`),...n)}}function p({enabledLogLevels:e=g}={}){return l.createLogger({...t.reduce((r,n)=>{const o=c[n];return r[o]=k(n,e),r},{})}).withMiddleware({...t.reduce((r,n)=>{const o=c[n];return r[o]=M(n),r},{})})}exports.LogLevel=u;exports.allLogLevels=t;exports.createCliLogger=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./cliLogger-xnFprY-d.cjs");exports.createCliLogger=e.createCliLogger;
package/dist/cli.js CHANGED
@@ -1,95 +1,4 @@
1
- import a from "chalk";
2
- import { createLogger as l, isContextualMessage as b } from "./index.js";
3
- var i = /* @__PURE__ */ ((e) => (e[e.Error = 0] = "Error", e[e.Warn = 1] = "Warn", e[e.Success = 2] = "Success", e[e.Info = 3] = "Info", e[e.Verbose = 4] = "Verbose", e[e.Debug = 5] = "Debug", e))(i || {});
4
- const c = [
5
- 0,
6
- 1,
7
- 2,
8
- 3,
9
- 4,
10
- 5
11
- /* Debug */
12
- ], g = [
13
- 0,
14
- 1,
15
- 2,
16
- 3
17
- /* Info */
18
- ], t = {
19
- 0: "error",
20
- 1: "warn",
21
- 2: "success",
22
- 3: "info",
23
- 4: "verbose",
24
- 5: "debug"
25
- }, d = {
26
- 0: a.red,
27
- 1: a.yellow,
28
- 2: a.green,
29
- 3: a.blue,
30
- 4: a.gray,
31
- 5: a.magenta
32
- };
33
- function f(e, s) {
34
- return s.includes(e);
35
- }
36
- function p(e, s) {
37
- return s.map((r) => b(r) ? r(e) : r);
38
- }
39
- function k(e, s) {
40
- return (r, ...n) => {
41
- if (f(e, s)) {
42
- const o = p(r, n);
43
- switch (e) {
44
- case 0:
45
- console.error(...o);
46
- break;
47
- case 1:
48
- console.warn(...o);
49
- break;
50
- case 2:
51
- console.log(...o);
52
- break;
53
- case 3:
54
- console.info(...o);
55
- break;
56
- case 4:
57
- console.log(...o);
58
- break;
59
- case 5:
60
- console.log(...o);
61
- break;
62
- }
63
- }
64
- };
65
- }
66
- function m(e) {
67
- return (s) => (r, ...n) => {
68
- const o = d[e], u = t[e];
69
- s(r, o(`[${u.toUpperCase()}]`), ...n);
70
- };
71
- }
72
- function h({ enabledLogLevels: e = g } = {}) {
73
- return l({
74
- ...c.reduce(
75
- (r, n) => {
76
- const o = t[n];
77
- return r[o] = k(n, e), r;
78
- },
79
- {}
80
- )
81
- }).withMiddleware({
82
- ...c.reduce(
83
- (r, n) => {
84
- const o = t[n];
85
- return r[o] = m(n), r;
86
- },
87
- {}
88
- )
89
- });
90
- }
1
+ import { c as o } from "./cliLogger-BIKHGxBN.js";
91
2
  export {
92
- i as LogLevel,
93
- c as allLogLevels,
94
- h as createCliLogger
3
+ o as createCliLogger
95
4
  };
@@ -0,0 +1,69 @@
1
+ import l from "chalk";
2
+ import { c as u, i } from "./logger-Xwf0bgzB.js";
3
+ import { a as c, l as t, d as b, i as d, L as r } from "./logLevels-DN78PoTJ.js";
4
+ const L = {
5
+ [r.Error]: l.red,
6
+ [r.Warn]: l.yellow,
7
+ [r.Success]: l.green,
8
+ [r.Info]: l.blue,
9
+ [r.Verbose]: l.gray,
10
+ [r.Debug]: l.magenta
11
+ };
12
+ function f(a, n) {
13
+ return n.map((e) => i(e) ? e(a) : e);
14
+ }
15
+ function m(a, n) {
16
+ return (e, ...s) => {
17
+ if (d(a, n)) {
18
+ const o = f(e, s);
19
+ switch (a) {
20
+ case r.Error:
21
+ console.error(...o);
22
+ break;
23
+ case r.Warn:
24
+ console.warn(...o);
25
+ break;
26
+ case r.Success:
27
+ console.log(...o);
28
+ break;
29
+ case r.Info:
30
+ console.info(...o);
31
+ break;
32
+ case r.Verbose:
33
+ console.log(...o);
34
+ break;
35
+ case r.Debug:
36
+ console.log(...o);
37
+ break;
38
+ }
39
+ }
40
+ };
41
+ }
42
+ function p(a) {
43
+ return (n) => (e, ...s) => {
44
+ const o = L[a], g = t[a];
45
+ n(e, o(`[${g.toUpperCase()}]`), ...s);
46
+ };
47
+ }
48
+ function h({ enabledLogLevels: a = b } = {}) {
49
+ return u({
50
+ ...c.reduce(
51
+ (e, s) => {
52
+ const o = t[s];
53
+ return e[o] = m(s, a), e;
54
+ },
55
+ {}
56
+ )
57
+ }).withMiddleware({
58
+ ...c.reduce(
59
+ (e, s) => {
60
+ const o = t[s];
61
+ return e[o] = p(s), e;
62
+ },
63
+ {}
64
+ )
65
+ });
66
+ }
67
+ export {
68
+ h as c
69
+ };
@@ -0,0 +1 @@
1
+ "use strict";const a=require("chalk"),L=require("./logger-CSPbXuiG.cjs"),e=require("./logLevels-B68KoC22.cjs"),c={[e.LogLevel.Error]:a.red,[e.LogLevel.Warn]:a.yellow,[e.LogLevel.Success]:a.green,[e.LogLevel.Info]:a.blue,[e.LogLevel.Verbose]:a.gray,[e.LogLevel.Debug]:a.magenta};function t(l,s){return s.map(o=>L.isContextualMessage(o)?o(l):o)}function u(l,s){return(o,...g)=>{if(e.isLogLevelEnabled(l,s)){const r=t(o,g);switch(l){case e.LogLevel.Error:console.error(...r);break;case e.LogLevel.Warn:console.warn(...r);break;case e.LogLevel.Success:console.log(...r);break;case e.LogLevel.Info:console.info(...r);break;case e.LogLevel.Verbose:console.log(...r);break;case e.LogLevel.Debug:console.log(...r);break}}}}function b(l){return s=>(o,...g)=>{const r=c[l],n=e.logLevelToLabel[l];s(o,r(`[${n.toUpperCase()}]`),...g)}}function i({enabledLogLevels:l=e.defaultEnabledLogLevels}={}){return L.createLogger({...e.allLogLevels.reduce((o,g)=>{const r=e.logLevelToLabel[g];return o[r]=u(g,l),o},{})}).withMiddleware({...e.allLogLevels.reduce((o,g)=>{const r=e.logLevelToLabel[g];return o[r]=b(g),o},{})})}exports.createCliLogger=i;
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function g(e){return typeof e=="function"}function l(e){return u({},e)}function u(e,a){const n={...a},r={};for(const t of Object.keys(n))Object.defineProperty(r,t,{value:(...o)=>{n[t](e,...o)},enumerable:!0,configurable:!0});return r.withMiddleware=t=>{const o={...n};for(const s of Object.keys(t)){const i=t[s],c=n[s];i&&c&&(o[s]=i(c))}return u(e,o)},r.withContext=t=>u({...e,...t},n),r}exports.createLogger=l;exports.isContextualMessage=g;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./logger-CSPbXuiG.cjs"),g=require("./json.cjs"),l=require("./nest.cjs"),e=require("./logLevels-B68KoC22.cjs"),r=require("./cliLogger-xnFprY-d.cjs");exports.createLogger=o.createLogger;exports.isContextualMessage=o.isContextualMessage;exports.createJsonLogger=g.createJsonLogger;exports.createNestJsonLogger=l.createNestJsonLogger;exports.LogLevel=e.LogLevel;exports.allLogLevels=e.allLogLevels;exports.defaultEnabledLogLevels=e.defaultEnabledLogLevels;exports.isLogLevelEnabled=e.isLogLevelEnabled;exports.logLevelToLabel=e.logLevelToLabel;exports.createCliLogger=r.createCliLogger;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,6 @@
1
1
  export * from './lib/logger';
2
+ export * from './lib/jsonLogger';
3
+ export * from './lib/nestLogger';
4
+ export * from './lib/logLevels';
5
+ export * from './lib/cliLogger';
2
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA"}
package/dist/index.js CHANGED
@@ -1,29 +1,17 @@
1
- function a(e) {
2
- return typeof e == "function";
3
- }
4
- function l(e) {
5
- return c({}, e);
6
- }
7
- function c(e, f) {
8
- const t = { ...f }, r = {};
9
- for (const n of Object.keys(t))
10
- Object.defineProperty(r, n, {
11
- value: (...o) => {
12
- t[n](e, ...o);
13
- },
14
- enumerable: !0,
15
- configurable: !0
16
- });
17
- return r.withMiddleware = (n) => {
18
- const o = { ...t };
19
- for (const u of Object.keys(n)) {
20
- const i = n[u], s = t[u];
21
- i && s && (o[u] = i(s));
22
- }
23
- return c(e, o);
24
- }, r.withContext = (n) => c({ ...e, ...n }, t), r;
25
- }
1
+ import { c as a, i as r } from "./logger-Xwf0bgzB.js";
2
+ import { createJsonLogger as l } from "./json.js";
3
+ import { createNestJsonLogger as g } from "./nest.js";
4
+ import { L as c, a as f, d as x, i, l as m } from "./logLevels-DN78PoTJ.js";
5
+ import { c as p } from "./cliLogger-BIKHGxBN.js";
26
6
  export {
27
- l as createLogger,
28
- a as isContextualMessage
7
+ c as LogLevel,
8
+ f as allLogLevels,
9
+ p as createCliLogger,
10
+ l as createJsonLogger,
11
+ a as createLogger,
12
+ g as createNestJsonLogger,
13
+ x as defaultEnabledLogLevels,
14
+ r as isContextualMessage,
15
+ i as isLogLevelEnabled,
16
+ m as logLevelToLabel
29
17
  };
package/dist/json.cjs ADDED
@@ -0,0 +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;
package/dist/json.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './lib/jsonLogger';
2
+ //# sourceMappingURL=json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA"}
package/dist/json.js ADDED
@@ -0,0 +1,40 @@
1
+ import { c, i as f } from "./logger-Xwf0bgzB.js";
2
+ import { a as l, l as n, d as u, i as m } from "./logLevels-DN78PoTJ.js";
3
+ function p(e, s) {
4
+ return s.map((t) => f(t) ? t(e) : t);
5
+ }
6
+ function L(e) {
7
+ return e instanceof Error ? { message: e.message, stack: e.stack } : e;
8
+ }
9
+ function d(e) {
10
+ return typeof e == "object" && e !== null ? JSON.stringify(e) : String(e);
11
+ }
12
+ function b(e, s) {
13
+ const t = n[e];
14
+ return (r, ...o) => {
15
+ if (!m(e, s))
16
+ return;
17
+ const a = p(r, o).map((g) => d(L(g))).join(" "), i = {
18
+ level: t,
19
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
20
+ msg: a,
21
+ ...Object.keys(r).length > 0 ? { context: r } : {}
22
+ };
23
+ process.stdout.write(JSON.stringify(i) + `
24
+ `);
25
+ };
26
+ }
27
+ function J({ enabledLogLevels: e = u } = {}) {
28
+ return c({
29
+ ...l.reduce(
30
+ (s, t) => {
31
+ const r = n[t];
32
+ return s[r] = b(t, e), s;
33
+ },
34
+ {}
35
+ )
36
+ });
37
+ }
38
+ export {
39
+ J as createJsonLogger
40
+ };
@@ -1,13 +1,5 @@
1
1
  import { MethodHandler } from './logger';
2
- declare enum LogLevel {
3
- Error = 0,
4
- Warn = 1,
5
- Success = 2,
6
- Info = 3,
7
- Verbose = 4,
8
- Debug = 5
9
- }
10
- declare const allLogLevels: LogLevel[];
2
+ import { LogLevel } from './logLevels';
11
3
  type CreateCliLoggerOptions = {
12
4
  enabledLogLevels?: LogLevel[];
13
5
  };
@@ -19,5 +11,5 @@ declare function createCliLogger({ enabledLogLevels }?: CreateCliLoggerOptions):
19
11
  verbose: MethodHandler<unknown>;
20
12
  debug: MethodHandler<unknown>;
21
13
  }>;
22
- export { allLogLevels, createCliLogger, LogLevel };
14
+ export { createCliLogger };
23
15
  //# sourceMappingURL=cliLogger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cliLogger.d.ts","sourceRoot":"","sources":["../../src/lib/cliLogger.ts"],"names":[],"mappings":"AAEA,OAAO,EAKL,aAAa,EAEd,MAAM,UAAU,CAAA;AAEjB,aAAK,QAAQ;IACX,KAAK,IAAI;IACT,IAAI,IAAI;IACR,OAAO,IAAI;IACX,IAAI,IAAI;IACR,OAAO,IAAI;IACX,KAAK,IAAI;CACV;AAED,QAAA,MAAM,YAAY,YAAqG,CAAA;AAwEvH,KAAK,sBAAsB,GAAG;IAAE,gBAAgB,CAAC,EAAE,QAAQ,EAAE,CAAA;CAAE,CAAA;AAE/D,iBAAS,eAAe,CAAC,EAAE,gBAA0C,EAAE,GAAE,sBAA2B;;;;;;;GAsBnG;AAED,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAA"}
1
+ {"version":3,"file":"cliLogger.d.ts","sourceRoot":"","sources":["../../src/lib/cliLogger.ts"],"names":[],"mappings":"AAEA,OAAO,EAKL,aAAa,EAEd,MAAM,UAAU,CAAA;AACjB,OAAO,EAIL,QAAQ,EAGT,MAAM,aAAa,CAAA;AAwDpB,KAAK,sBAAsB,GAAG;IAAE,gBAAgB,CAAC,EAAE,QAAQ,EAAE,CAAA;CAAE,CAAA;AAE/D,iBAAS,eAAe,CAAC,EAAE,gBAA0C,EAAE,GAAE,sBAA2B;;;;;;;GAsBnG;AAED,OAAO,EAAE,eAAe,EAAE,CAAA"}
@@ -0,0 +1,15 @@
1
+ import { MethodHandler } from './logger';
2
+ import { LogLevel } from './logLevels';
3
+ type CreateJsonLoggerOptions = {
4
+ enabledLogLevels?: LogLevel[];
5
+ };
6
+ declare function createJsonLogger({ enabledLogLevels }?: CreateJsonLoggerOptions): import('./logger').Logger<{}, {
7
+ error: MethodHandler<unknown>;
8
+ warn: MethodHandler<unknown>;
9
+ success: MethodHandler<unknown>;
10
+ info: MethodHandler<unknown>;
11
+ verbose: MethodHandler<unknown>;
12
+ debug: MethodHandler<unknown>;
13
+ }>;
14
+ export { createJsonLogger };
15
+ //# sourceMappingURL=jsonLogger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonLogger.d.ts","sourceRoot":"","sources":["../../src/lib/jsonLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,aAAa,EAEd,MAAM,UAAU,CAAA;AACjB,OAAO,EAIL,QAAQ,EAGT,MAAM,aAAa,CAAA;AAyCpB,KAAK,uBAAuB,GAAG;IAAE,gBAAgB,CAAC,EAAE,QAAQ,EAAE,CAAA;CAAE,CAAA;AAEhE,iBAAS,gBAAgB,CAAC,EAAE,gBAA0C,EAAE,GAAE,uBAA4B;;;;;;;GAWrG;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAA"}
@@ -0,0 +1,23 @@
1
+ declare enum LogLevel {
2
+ Error = 0,
3
+ Warn = 1,
4
+ Success = 2,
5
+ Info = 3,
6
+ Verbose = 4,
7
+ Debug = 5
8
+ }
9
+ declare const allLogLevels: LogLevel[];
10
+ declare const defaultEnabledLogLevels: LogLevel[];
11
+ declare const logLevelToLabel: {
12
+ readonly 0: "error";
13
+ readonly 1: "warn";
14
+ readonly 2: "success";
15
+ readonly 3: "info";
16
+ readonly 4: "verbose";
17
+ readonly 5: "debug";
18
+ };
19
+ type LogLevelLabel = (typeof logLevelToLabel)[keyof typeof logLevelToLabel];
20
+ declare function isLogLevelEnabled(logLevel: LogLevel, enabledLogLevels: LogLevel[]): boolean;
21
+ export { allLogLevels, defaultEnabledLogLevels, isLogLevelEnabled, LogLevel, logLevelToLabel };
22
+ export type { LogLevelLabel };
23
+ //# sourceMappingURL=logLevels.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logLevels.d.ts","sourceRoot":"","sources":["../../src/lib/logLevels.ts"],"names":[],"mappings":"AAAA,aAAK,QAAQ;IACX,KAAK,IAAI;IACT,IAAI,IAAI;IACR,OAAO,IAAI;IACX,IAAI,IAAI;IACR,OAAO,IAAI;IACX,KAAK,IAAI;CACV;AAED,QAAA,MAAM,YAAY,YAAqG,CAAA;AAEvH,QAAA,MAAM,uBAAuB,YAAmE,CAAA;AAEhG,QAAA,MAAM,eAAe;;;;;;;CAOX,CAAA;AAEV,KAAK,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,OAAO,eAAe,CAAC,CAAA;AAE3E,iBAAS,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,EAAE,gBAAgB,EAAE,QAAQ,EAAE,WAE1E;AAED,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAA;AAC9F,YAAY,EAAE,aAAa,EAAE,CAAA"}
@@ -0,0 +1,11 @@
1
+ export interface LoggerService {
2
+ log(message: any, ...optionalParams: any[]): any;
3
+ error(message: any, ...optionalParams: any[]): any;
4
+ warn(message: any, ...optionalParams: any[]): any;
5
+ debug?(message: any, ...optionalParams: any[]): any;
6
+ verbose?(message: any, ...optionalParams: any[]): any;
7
+ fatal?(message: any, ...optionalParams: any[]): any;
8
+ setLogLevels?(levels: any[]): any;
9
+ }
10
+ export declare function createNestJsonLogger(): LoggerService;
11
+ //# sourceMappingURL=nestLogger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nestLogger.d.ts","sourceRoot":"","sources":["../../src/lib/nestLogger.ts"],"names":[],"mappings":"AAgCA,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,EAAE,GAAG,GAAG,CAAA;IAChD,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,EAAE,GAAG,GAAG,CAAA;IAClD,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,EAAE,GAAG,GAAG,CAAA;IACjD,KAAK,CAAC,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,EAAE,GAAG,GAAG,CAAA;IACnD,OAAO,CAAC,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,EAAE,GAAG,GAAG,CAAA;IACrD,KAAK,CAAC,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,EAAE,GAAG,GAAG,CAAA;IACnD,YAAY,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,CAAA;CAClC;AAED,wBAAgB,oBAAoB,IAAI,aAAa,CA8BpD"}
@@ -0,0 +1 @@
1
+ "use strict";var e=(s=>(s[s.Error=0]="Error",s[s.Warn=1]="Warn",s[s.Success=2]="Success",s[s.Info=3]="Info",s[s.Verbose=4]="Verbose",s[s.Debug=5]="Debug",s))(e||{});const n=[0,1,2,3,4,5],a=[0,1,2,3],l={0:"error",1:"warn",2:"success",3:"info",4:"verbose",5:"debug"};function o(s,r){return r.includes(s)}exports.LogLevel=e;exports.allLogLevels=n;exports.defaultEnabledLogLevels=a;exports.isLogLevelEnabled=o;exports.logLevelToLabel=l;
@@ -0,0 +1,33 @@
1
+ var n = /* @__PURE__ */ ((s) => (s[s.Error = 0] = "Error", s[s.Warn = 1] = "Warn", s[s.Success = 2] = "Success", s[s.Info = 3] = "Info", s[s.Verbose = 4] = "Verbose", s[s.Debug = 5] = "Debug", s))(n || {});
2
+ const a = [
3
+ 0,
4
+ 1,
5
+ 2,
6
+ 3,
7
+ 4,
8
+ 5
9
+ /* Debug */
10
+ ], c = [
11
+ 0,
12
+ 1,
13
+ 2,
14
+ 3
15
+ /* Info */
16
+ ], u = {
17
+ 0: "error",
18
+ 1: "warn",
19
+ 2: "success",
20
+ 3: "info",
21
+ 4: "verbose",
22
+ 5: "debug"
23
+ };
24
+ function b(s, r) {
25
+ return r.includes(s);
26
+ }
27
+ export {
28
+ n as L,
29
+ a,
30
+ c as d,
31
+ b as i,
32
+ u as l
33
+ };
@@ -0,0 +1 @@
1
+ "use strict";function f(e){return typeof e=="function"}function g(e){return u({},e)}function u(e,a){const n={...a},r={};for(const t of Object.keys(n))Object.defineProperty(r,t,{value:(...o)=>{n[t](e,...o)},enumerable:!0,configurable:!0});return r.withMiddleware=t=>{const o={...n};for(const s of Object.keys(t)){const c=t[s],i=n[s];c&&i&&(o[s]=c(i))}return u(e,o)},r.withContext=t=>u({...e,...t},n),r}exports.createLogger=g;exports.isContextualMessage=f;
@@ -0,0 +1,29 @@
1
+ function f(e) {
2
+ return typeof e == "function";
3
+ }
4
+ function l(e) {
5
+ return c({}, e);
6
+ }
7
+ function c(e, a) {
8
+ const t = { ...a }, r = {};
9
+ for (const n of Object.keys(t))
10
+ Object.defineProperty(r, n, {
11
+ value: (...o) => {
12
+ t[n](e, ...o);
13
+ },
14
+ enumerable: !0,
15
+ configurable: !0
16
+ });
17
+ return r.withMiddleware = (n) => {
18
+ const o = { ...t };
19
+ for (const s of Object.keys(n)) {
20
+ const i = n[s], u = t[s];
21
+ i && u && (o[s] = i(u));
22
+ }
23
+ return c(e, o);
24
+ }, r.withContext = (n) => c({ ...e, ...n }, t), r;
25
+ }
26
+ export {
27
+ l as c,
28
+ f as i
29
+ };
package/dist/nest.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./logger-CSPbXuiG.cjs");function u(r,t){return[r,...t].map(o=>o instanceof Error?o.message:typeof o=="object"&&o!==null?JSON.stringify(o):String(o)).join(" ")}function f(r,t,e){const o=e.at(-1),s=typeof o=="string"?o:void 0,g=s!==void 0?e.slice(0,-1):e,a=u(t,g),i={level:r,timestamp:new Date().toISOString(),message:a,...s!==void 0?{context:s}:{}};process.stdout.write(JSON.stringify(i)+`
2
+ `)}function n(r){return(t,...e)=>{const[o="",...s]=e;f(r,o,s)}}function l(){const r=c.createLogger({log:n("info"),error:n("error"),warn:n("warn"),debug:n("debug"),verbose:n("verbose"),fatal:n("fatal")});return{log(t,...e){r.log(t,...e)},error(t,...e){r.error(t,...e)},warn(t,...e){r.warn(t,...e)},debug(t,...e){r.debug(t,...e)},verbose(t,...e){r.verbose(t,...e)},fatal(t,...e){r.fatal(t,...e)}}}exports.createNestJsonLogger=l;
package/dist/nest.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './lib/nestLogger';
2
+ //# sourceMappingURL=nest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nest.d.ts","sourceRoot":"","sources":["../src/nest.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA"}
package/dist/nest.js ADDED
@@ -0,0 +1,53 @@
1
+ import { c } from "./logger-Xwf0bgzB.js";
2
+ function f(t, r) {
3
+ return [t, ...r].map((o) => o instanceof Error ? o.message : typeof o == "object" && o !== null ? JSON.stringify(o) : String(o)).join(" ");
4
+ }
5
+ function u(t, r, e) {
6
+ const o = e.at(-1), s = typeof o == "string" ? o : void 0, a = s !== void 0 ? e.slice(0, -1) : e, g = f(r, a), i = {
7
+ level: t,
8
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
9
+ message: g,
10
+ ...s !== void 0 ? { context: s } : {}
11
+ };
12
+ process.stdout.write(JSON.stringify(i) + `
13
+ `);
14
+ }
15
+ function n(t) {
16
+ return (r, ...e) => {
17
+ const [o = "", ...s] = e;
18
+ u(t, o, s);
19
+ };
20
+ }
21
+ function m() {
22
+ const t = c({
23
+ log: n("info"),
24
+ error: n("error"),
25
+ warn: n("warn"),
26
+ debug: n("debug"),
27
+ verbose: n("verbose"),
28
+ fatal: n("fatal")
29
+ });
30
+ return {
31
+ log(r, ...e) {
32
+ t.log(r, ...e);
33
+ },
34
+ error(r, ...e) {
35
+ t.error(r, ...e);
36
+ },
37
+ warn(r, ...e) {
38
+ t.warn(r, ...e);
39
+ },
40
+ debug(r, ...e) {
41
+ t.debug(r, ...e);
42
+ },
43
+ verbose(r, ...e) {
44
+ t.verbose(r, ...e);
45
+ },
46
+ fatal(r, ...e) {
47
+ t.fatal(r, ...e);
48
+ }
49
+ };
50
+ }
51
+ export {
52
+ m as createNestJsonLogger
53
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leancodepl/logger",
3
- "version": "9.7.2",
3
+ "version": "9.7.3",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -17,6 +17,16 @@
17
17
  "types": "./dist/cli.d.ts",
18
18
  "import": "./dist/cli.js",
19
19
  "default": "./dist/cli.js"
20
+ },
21
+ "./json": {
22
+ "types": "./dist/json.d.ts",
23
+ "import": "./dist/json.js",
24
+ "default": "./dist/json.js"
25
+ },
26
+ "./nest": {
27
+ "types": "./dist/nest.d.ts",
28
+ "import": "./dist/nest.js",
29
+ "default": "./dist/nest.js"
20
30
  }
21
31
  },
22
32
  "dependencies": {
@@ -61,4 +71,4 @@
61
71
  "CHANGELOG.md",
62
72
  "!**/*.tsbuildinfo"
63
73
  ]
64
- }
74
+ }