@eventuras/logger 0.9.0 → 0.9.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/dist/Logger.d.ts CHANGED
@@ -1,4 +1,32 @@
1
- import { ErrorLoggerOptions, LoggerConfig, LoggerOptions, LogTransport } from './types';
1
+ /**
2
+ * Structured logger with pluggable transports.
3
+ *
4
+ * Uses a `LogTransport` abstraction so the logging backend can be swapped
5
+ * without changing application code. Ships with PinoTransport (default,
6
+ * production-grade) and ConsoleTransport (browser/testing).
7
+ *
8
+ * Standard log levels:
9
+ * fatal: 60 | error: 50 | warn: 40 | info: 30 | debug: 20 | trace: 10
10
+ *
11
+ * @example
12
+ * // Scoped logger (recommended pattern)
13
+ * const logger = Logger.create({
14
+ * namespace: 'CollectionEditor',
15
+ * context: { collectionId: 123 },
16
+ * });
17
+ * logger.info('Event added', { eventId: 456 });
18
+ *
19
+ * @example
20
+ * // Static one-off logs
21
+ * Logger.info('Simple message');
22
+ * Logger.error({ error: err }, 'Something failed');
23
+ *
24
+ * @example
25
+ * // Custom transport
26
+ * import { ConsoleTransport } from '@eventuras/logger';
27
+ * Logger.configure({ transport: new ConsoleTransport() });
28
+ */
29
+ import type { ErrorLoggerOptions, LoggerConfig, LoggerOptions, LogTransport } from './types';
2
30
  export declare class Logger {
3
31
  private static transport;
4
32
  private static config;
package/dist/node.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { PinoTransportOptions } from './transports/pino';
2
- import { LoggerConfig } from './types';
1
+ import { type PinoTransportOptions } from './transports/pino';
2
+ import type { LoggerConfig } from './types';
3
3
  export { formatLogLine, createPrettyStream } from './transports/pretty';
4
4
  /** Options for `configureNodeLogger`. */
5
5
  export type NodeLoggerOptions = Omit<LoggerConfig, 'transport'> & {
@@ -1,4 +1,10 @@
1
- import { LogLevel, LogTransport } from '../types';
1
+ /**
2
+ * Console-based transport for browser environments and testing.
3
+ *
4
+ * Uses `console.log/warn/error` — no dependencies, works everywhere.
5
+ * Useful as a lightweight fallback when Pino is not available or desired.
6
+ */
7
+ import type { LogLevel, LogTransport } from '../types';
2
8
  export declare class ConsoleTransport implements LogTransport {
3
9
  private readonly bindings;
4
10
  /** Create a ConsoleTransport with optional pre-bound context fields. */
@@ -1,5 +1,15 @@
1
- import { Logger as PinoLogger, LoggerOptions as PinoLoggerOptions } from 'pino';
2
- import { LogLevel, LogTransport } from '../types';
1
+ /**
2
+ * Pino-based transport the default production backend.
3
+ *
4
+ * Wraps a Pino logger instance to satisfy the `LogTransport` interface,
5
+ * keeping Pino as an implementation detail that consumers never interact with directly.
6
+ *
7
+ * For pretty-printed dev output, see `configureNodeLogger` in
8
+ * `@eventuras/logger/node` — this module intentionally stays free of
9
+ * `node:stream` imports so the main entry stays browser/edge-safe.
10
+ */
11
+ import { type Logger as PinoLogger, type LoggerOptions as PinoLoggerOptions } from 'pino';
12
+ import type { LogLevel, LogTransport } from '../types';
3
13
  /**
4
14
  * Minimal structural type for a Pino destination stream — accepts anything
5
15
  * with a `write` method. Defined locally so this file (re-exported from the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eventuras/logger",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "Structured logging with Pino and optional OpenTelemetry integration",
5
5
  "keywords": [
6
6
  "logger",
@@ -47,11 +47,12 @@
47
47
  "devDependencies": {
48
48
  "@opentelemetry/api": "^1.9.1",
49
49
  "@opentelemetry/sdk-logs": "^0.222.0",
50
+ "typescript": "^6.0.2",
50
51
  "vite": "^8.1.0",
51
52
  "vitest": "^5.0.0",
52
53
  "@eventuras/eslint-config": "1.0.5",
53
- "@eventuras/typescript-config": "1.0.0",
54
- "@eventuras/vite-config": "0.3.1"
54
+ "@eventuras/typescript-config": "1.1.0",
55
+ "@eventuras/vite-config": "0.4.0"
55
56
  },
56
57
  "peerDependencies": {
57
58
  "@opentelemetry/sdk-logs": ">=0.200.0 <1.0.0"
@@ -65,7 +66,7 @@
65
66
  "node": ">=20"
66
67
  },
67
68
  "scripts": {
68
- "build": "vite build",
69
+ "build": "vite build && tsc -p tsconfig.build.json --emitDeclarationOnly",
69
70
  "dev": "vite build --watch",
70
71
  "test": "vitest run",
71
72
  "test:watch": "vitest"