@holz/console-backend 0.5.0 → 0.6.1

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/README.md ADDED
@@ -0,0 +1,27 @@
1
+ # `@holz/console-backend`
2
+
3
+ Pretty-print logs to the browser console.
4
+
5
+ <img alt="Screenshot of logs printed to the browser console" src="https://user-images.githubusercontent.com/10053423/222927532-2925b0a3-9494-4de7-b328-917ceb8607b0.png" width="600" />
6
+
7
+ ## Usage
8
+
9
+ ```typescript
10
+ import { createConsoleBackend } from '@holz/console-backend';
11
+
12
+ const logger = createLogger(createConsoleBackend());
13
+ ```
14
+
15
+ > **Note**
16
+ > This is fine-tuned for an interactive browser console. If you want pretty-printed logs in Node or Deno, try [`@holz/ansi-terminal-backend`](https://github.com/PsychoLlama/holz/tree/main/packages/holz-ansi-terminal-backend) instead.
17
+
18
+ ## Options
19
+
20
+ ```typescript
21
+ createConsoleBackend({
22
+ /**
23
+ * By default it prints to the global console, but you can override it.
24
+ */
25
+ console: typeof console,
26
+ });
27
+ ```
@@ -6,7 +6,7 @@ function l(s = {}) {
6
6
  const r = s.console ?? console;
7
7
  let e;
8
8
  return (t) => {
9
- const n = new Date(), c = [
9
+ const n = /* @__PURE__ */ new Date(), c = [
10
10
  {
11
11
  include: !0,
12
12
  format: "%s",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@holz/console-backend",
3
- "version": "0.5.0",
3
+ "version": "0.6.1",
4
4
  "description": "A console backend for Holz",
5
5
  "type": "module",
6
6
  "main": "./dist/holz-console-backend.cjs",
@@ -38,12 +38,15 @@
38
38
  "test:unit": "vitest --color --passWithNoTests",
39
39
  "test:types": "tsc"
40
40
  },
41
+ "peerDependencies": {
42
+ "@holz/core": "0.6.0"
43
+ },
41
44
  "devDependencies": {
42
- "@holz/core": "^0.5.0",
45
+ "@holz/core": "^0.6.0",
43
46
  "@types/node": "^18.14.0",
44
- "@vitest/coverage-c8": "^0.28.5",
45
- "typescript": "^4.9.5",
47
+ "@vitest/coverage-v8": "^0.33.0",
48
+ "typescript": "^5.0.0",
46
49
  "vite": "^4.0.0",
47
- "vitest": "^0.28.5"
50
+ "vitest": "^0.33.0"
48
51
  }
49
52
  }
@@ -1,4 +1,4 @@
1
- // Vitest Snapshot v1
1
+ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
2
 
3
3
  exports[`Console backend > avoids changing debug messages 1`] = `
4
4
  [
@@ -36,7 +36,7 @@ describe('Console backend', () => {
36
36
  logger.info('hello world');
37
37
 
38
38
  expect(output.print).toHaveBeenCalledWith(
39
- expect.stringContaining('hello world')
39
+ expect.stringContaining('hello world'),
40
40
  );
41
41
  });
42
42
 
@@ -50,7 +50,7 @@ describe('Console backend', () => {
50
50
  logger.debug('initialized');
51
51
 
52
52
  expect(output.print).toHaveBeenCalledWith(
53
- expect.stringContaining('my-lib:MyClass')
53
+ expect.stringContaining('my-lib:MyClass'),
54
54
  );
55
55
  });
56
56
 
@@ -63,7 +63,7 @@ describe('Console backend', () => {
63
63
 
64
64
  // Hard to test without replicating the implementation.
65
65
  expect(output.print).toHaveBeenCalledWith(
66
- expect.stringContaining('sessionId')
66
+ expect.stringContaining('sessionId'),
67
67
  );
68
68
 
69
69
  expect(output.print).toHaveBeenCalledWith(expect.stringContaining('3109'));
@@ -111,7 +111,7 @@ describe('Console backend', () => {
111
111
  const backend = createConsoleBackend({ console: output });
112
112
  const logger = namespace.reduce(
113
113
  (logger, ns) => logger.namespace(ns),
114
- createLogger(backend)
114
+ createLogger(backend),
115
115
  );
116
116
 
117
117
  logger[method](message, { id: 1234 });