@holz/console-backend 0.8.0-rc.1 → 0.8.0-rc.2

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o={fatal:60,error:50,warn:40,info:30,debug:20,trace:10},c=1e3,u=60*c,i=60*u,f=24*i,g=(a,s=a)=>{const t=a.getTime()-s.getTime(),e=Math.abs(t),n=t<0?"":"+";return e>=f?`${n}${Math.round(t/f)}d`:e>=i?`${n}${Math.round(t/i)}h`:e>=u?`${n}${Math.round(t/u)}m`:e>=c?`${n}${Math.round(t/c)}s`:`${n}${t}ms`},$=(a={})=>{const s=a.console??console;let t;return e=>{const n=new Date,l=[{include:!0,format:"%s",values:[e.message]},{include:Object.keys(e.context).length>0,format:"%o",values:[e.context]},{include:!0,format:"%c%s",values:["color: gray",g(n,t)]},{include:e.origin.length>0,format:"%c%s",values:["color: rgba(128, 128, 128, 0.6); font-style: italic",e.origin.join(":")]}].filter(r=>r.include),d=l.map(r=>r.format).join(" "),m=l.flatMap(r=>r.values);s[h[e.level]](d,...m),t=n}},h={[o.trace]:"trace",[o.debug]:"debug",[o.info]:"info",[o.warn]:"warn",[o.error]:"error",[o.fatal]:"error"};exports.createConsoleBackend=$;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r={fatal:60,error:50,warn:40,info:30,debug:20,trace:10},c=1e3,i=60*c,u=60*i,f=24*u,g=(a,s=a)=>{const t=a.getTime()-s.getTime(),e=Math.abs(t),n=t<0?"":"+";return e>=f?`${n}${Math.round(t/f)}d`:e>=u?`${n}${Math.round(t/u)}h`:e>=i?`${n}${Math.round(t/i)}m`:e>=c?`${n}${Math.round(t/c)}s`:`${n}${t}ms`},$=(a={})=>{const s=a.console??console;let t;return e=>{const n=new Date(e.timestamp),l=[{include:!0,format:"%s",values:[e.message]},{include:Object.keys(e.context).length>0,format:"%o",values:[e.context]},{include:!0,format:"%c%s",values:["color: gray",g(n,t)]},{include:e.origin.length>0,format:"%c%s",values:["color: rgba(128, 128, 128, 0.6); font-style: italic",e.origin.join(":")]}].filter(o=>o.include),m=l.map(o=>o.format).join(" "),d=l.flatMap(o=>o.values);s[h[e.level]](m,...d),t=n}},h={[r.trace]:"trace",[r.debug]:"debug",[r.info]:"info",[r.warn]:"warn",[r.error]:"error",[r.fatal]:"error"};exports.createConsoleBackend=$;
@@ -11,14 +11,14 @@ const r = {
11
11
  debug: 20,
12
12
  /** Extremely detailed progress updates (usually hidden). */
13
13
  trace: 10
14
- }, c = 1e3, u = 60 * c, i = 60 * u, f = 24 * i, $ = (s, a = s) => {
15
- const e = s.getTime() - a.getTime(), t = Math.abs(e), n = e < 0 ? "" : "+";
16
- return t >= f ? `${n}${Math.round(e / f)}d` : t >= i ? `${n}${Math.round(e / i)}h` : t >= u ? `${n}${Math.round(e / u)}m` : t >= c ? `${n}${Math.round(e / c)}s` : `${n}${e}ms`;
17
- }, h = (s = {}) => {
18
- const a = s.console ?? console;
14
+ }, c = 1e3, i = 60 * c, u = 60 * i, f = 24 * u, $ = (a, s = a) => {
15
+ const e = a.getTime() - s.getTime(), t = Math.abs(e), n = e < 0 ? "" : "+";
16
+ return t >= f ? `${n}${Math.round(e / f)}d` : t >= u ? `${n}${Math.round(e / u)}h` : t >= i ? `${n}${Math.round(e / i)}m` : t >= c ? `${n}${Math.round(e / c)}s` : `${n}${e}ms`;
17
+ }, g = (a = {}) => {
18
+ const s = a.console ?? console;
19
19
  let e;
20
20
  return (t) => {
21
- const n = /* @__PURE__ */ new Date(), l = [
21
+ const n = new Date(t.timestamp), l = [
22
22
  {
23
23
  include: !0,
24
24
  format: "%s",
@@ -43,10 +43,10 @@ const r = {
43
43
  t.origin.join(":")
44
44
  ]
45
45
  }
46
- ].filter((o) => o.include), d = l.map((o) => o.format).join(" "), m = l.flatMap((o) => o.values);
47
- a[g[t.level]](d, ...m), e = n;
46
+ ].filter((o) => o.include), m = l.map((o) => o.format).join(" "), d = l.flatMap((o) => o.values);
47
+ s[h[t.level]](m, ...d), e = n;
48
48
  };
49
- }, g = {
49
+ }, h = {
50
50
  [r.trace]: "trace",
51
51
  [r.debug]: "debug",
52
52
  [r.info]: "info",
@@ -55,5 +55,5 @@ const r = {
55
55
  [r.fatal]: "error"
56
56
  };
57
57
  export {
58
- h as createConsoleBackend
58
+ g as createConsoleBackend
59
59
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@holz/console-backend",
3
- "version": "0.8.0-rc.1",
3
+ "version": "0.8.0-rc.2",
4
4
  "description": "A console backend for Holz",
5
5
  "type": "module",
6
6
  "repository": {
@@ -37,10 +37,10 @@
37
37
  "test:types": "tsc"
38
38
  },
39
39
  "peerDependencies": {
40
- "@holz/core": "^0.8.0-rc.1"
40
+ "@holz/core": "^0.8.0-rc.2"
41
41
  },
42
42
  "devDependencies": {
43
- "@holz/core": "^0.8.0-rc.1",
43
+ "@holz/core": "^0.8.0-rc.2",
44
44
  "@types/node": "^22.0.0",
45
45
  "@vitest/coverage-v8": "^3.0.8",
46
46
  "typescript": "^5.8.2",
@@ -10,7 +10,7 @@ export const createConsoleBackend = (options: Options = {}): LogProcessor => {
10
10
  let lastTimestamp: Date;
11
11
 
12
12
  return (log: Log) => {
13
- const now = new Date();
13
+ const time = new Date(log.timestamp);
14
14
 
15
15
  const segments = [
16
16
  {
@@ -26,7 +26,7 @@ export const createConsoleBackend = (options: Options = {}): LogProcessor => {
26
26
  {
27
27
  include: true,
28
28
  format: '%c%s',
29
- values: ['color: gray', timeDelta(now, lastTimestamp)],
29
+ values: ['color: gray', timeDelta(time, lastTimestamp)],
30
30
  },
31
31
  {
32
32
  include: log.origin.length > 0,
@@ -45,7 +45,7 @@ export const createConsoleBackend = (options: Options = {}): LogProcessor => {
45
45
  output[sink[log.level]](format, ...values);
46
46
 
47
47
  // Track the time spent between logs.
48
- lastTimestamp = now;
48
+ lastTimestamp = time;
49
49
  };
50
50
  };
51
51