@outfitter/logging 0.1.0-rc.3 → 0.1.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/dist/index.d.ts CHANGED
@@ -302,6 +302,33 @@ interface PrettyFormatterOptions {
302
302
  timestamp?: boolean;
303
303
  }
304
304
  /**
305
+ * Options for the console sink.
306
+ *
307
+ * Controls ANSI color output for terminal display. By default, colors are
308
+ * auto-detected based on whether stdout is a TTY.
309
+ *
310
+ * @example
311
+ * ```typescript
312
+ * // Auto-detect TTY (default)
313
+ * const sink = createConsoleSink();
314
+ *
315
+ * // Force colors off (for piped output, CI)
316
+ * const plainSink = createConsoleSink({ colors: false });
317
+ *
318
+ * // Force colors on (even in non-TTY)
319
+ * const colorSink = createConsoleSink({ colors: true });
320
+ * ```
321
+ */
322
+ interface ConsoleSinkOptions {
323
+ /**
324
+ * Enable ANSI colors in output.
325
+ * - `undefined` (default): Auto-detect based on stdout TTY status
326
+ * - `true`: Always use colors
327
+ * - `false`: Never use colors
328
+ */
329
+ colors?: boolean;
330
+ }
331
+ /**
305
332
  * Options for the file sink.
306
333
  *
307
334
  * Configures the file path and append behavior for file-based logging.
@@ -447,6 +474,7 @@ declare function createPrettyFormatter(options?: PrettyFormatterOptions): Format
447
474
  * Create a console sink that writes to stdout/stderr.
448
475
  * Info and below go to stdout, warn and above go to stderr.
449
476
  *
477
+ * @param options - Console sink options
450
478
  * @returns Sink configured for console output
451
479
  *
452
480
  * @example
@@ -455,9 +483,15 @@ declare function createPrettyFormatter(options?: PrettyFormatterOptions): Format
455
483
  * name: "app",
456
484
  * sinks: [createConsoleSink()],
457
485
  * });
486
+ *
487
+ * // Disable colors for CI/piped output
488
+ * const plainLogger = createLogger({
489
+ * name: "app",
490
+ * sinks: [createConsoleSink({ colors: false })],
491
+ * });
458
492
  * ```
459
493
  */
460
- declare function createConsoleSink(): Sink;
494
+ declare function createConsoleSink(options?: ConsoleSinkOptions): Sink;
461
495
  /**
462
496
  * Create a file sink that writes to a specified file path.
463
497
  *
@@ -501,4 +535,4 @@ declare function configureRedaction(config: GlobalRedactionConfig): void;
501
535
  * ```
502
536
  */
503
537
  declare function flush(): Promise<void>;
504
- export { flush, createPrettyFormatter, createLogger, createJsonFormatter, createFileSink, createConsoleSink, createChildLogger, configureRedaction, Sink, RedactionConfig, PrettyFormatterOptions, LoggerInstance, LoggerConfig, LogRecord, LogLevel, GlobalRedactionConfig, Formatter, FileSinkOptions, DEFAULT_PATTERNS };
538
+ export { flush, createPrettyFormatter, createLogger, createJsonFormatter, createFileSink, createConsoleSink, createChildLogger, configureRedaction, Sink, RedactionConfig, PrettyFormatterOptions, LoggerInstance, LoggerConfig, LogRecord, LogLevel, GlobalRedactionConfig, Formatter, FileSinkOptions, DEFAULT_PATTERNS, ConsoleSinkOptions };
package/dist/index.js CHANGED
@@ -286,8 +286,9 @@ function createPrettyFormatter(options) {
286
286
  }
287
287
  };
288
288
  }
289
- function createConsoleSink() {
290
- const formatter = createPrettyFormatter({ colors: true });
289
+ function createConsoleSink(options) {
290
+ const useColors = options?.colors ?? process.stdout.isTTY ?? false;
291
+ const formatter = createPrettyFormatter({ colors: useColors });
291
292
  const sink = {
292
293
  formatter,
293
294
  write(record, formatted) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@outfitter/logging",
3
3
  "description": "Structured logging via logtape with redaction support for Outfitter",
4
- "version": "0.1.0-rc.3",
4
+ "version": "0.1.0",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"
@@ -27,7 +27,7 @@
27
27
  "clean": "rm -rf dist"
28
28
  },
29
29
  "dependencies": {
30
- "@outfitter/contracts": "0.1.0-rc.2",
30
+ "@outfitter/contracts": "0.1.0",
31
31
  "@logtape/logtape": "^2.0.0"
32
32
  },
33
33
  "devDependencies": {