@travetto/log 7.0.4 → 7.0.6

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 CHANGED
@@ -16,7 +16,7 @@ yarn add @travetto/log
16
16
  This module provides logging functionality, building upon [ConsoleManager](https://github.com/travetto/travetto/tree/main/module/runtime/src/console.ts#L43) in the [Runtime](https://github.com/travetto/travetto/tree/main/module/runtime#readme "Runtime for travetto applications.") module. This is all ultimately built upon [console](https://nodejs.org/api/console.html) operations. The logging infrastructure is built upon the [Dependency Injection](https://github.com/travetto/travetto/tree/main/module/di#readme "Dependency registration/management and injection support.") system, and so new loggers can be created that rely upon dependency injected services and sources.
17
17
 
18
18
  ## Extending the Common Logger
19
- By default, the system ships with the [CommonLogger](https://github.com/travetto/travetto/tree/main/module/log/src/common.ts#L13), and by default will leverage the [LineLogFormatter](https://github.com/travetto/travetto/tree/main/module/log/src/formatter/line.ts#L37) and the [ConsoleLogAppender](https://github.com/travetto/travetto/tree/main/module/log/src/appender/console.ts#L7). The configuration [CommonLoggerConfig](https://github.com/travetto/travetto/tree/main/module/log/src/common.ts#L13) provides two configuration variables that allows for switching out [LineLogFormatter](https://github.com/travetto/travetto/tree/main/module/log/src/formatter/line.ts#L37) for the [JsonLogFormatter](https://github.com/travetto/travetto/tree/main/module/log/src/formatter/json.ts#L16), depending on the value of `CommonLoggerConfig.format`. Additionally the [ConsoleLogAppender](https://github.com/travetto/travetto/tree/main/module/log/src/appender/console.ts#L7) can be swapped out for the [FileLogAppender](https://github.com/travetto/travetto/tree/main/module/log/src/appender/file.ts#L11) depending on the value of `CommonLoggerConfig.output`.
19
+ By default, the system ships with the [CommonLogger](https://github.com/travetto/travetto/tree/main/module/log/src/common.ts#L13), and by default will leverage the [LineLogFormatter](https://github.com/travetto/travetto/tree/main/module/log/src/formatter/line.ts#L39) and the [ConsoleLogAppender](https://github.com/travetto/travetto/tree/main/module/log/src/appender/console.ts#L7). The configuration [CommonLoggerConfig](https://github.com/travetto/travetto/tree/main/module/log/src/common.ts#L13) provides two configuration variables that allows for switching out [LineLogFormatter](https://github.com/travetto/travetto/tree/main/module/log/src/formatter/line.ts#L39) for the [JsonLogFormatter](https://github.com/travetto/travetto/tree/main/module/log/src/formatter/json.ts#L16), depending on the value of `CommonLoggerConfig.format`. Additionally the [ConsoleLogAppender](https://github.com/travetto/travetto/tree/main/module/log/src/appender/console.ts#L7) can be swapped out for the [FileLogAppender](https://github.com/travetto/travetto/tree/main/module/log/src/appender/file.ts#L11) depending on the value of `CommonLoggerConfig.output`.
20
20
 
21
21
  **Code: Standard Logging Config**
22
22
  ```typescript
@@ -34,7 +34,7 @@ In addition to these simple overrides, the [CommonLogger](https://github.com/tra
34
34
  **Code: Sample Common Formatter**
35
35
  ```typescript
36
36
  import { Injectable } from '@travetto/di';
37
- import { LogFormatter, LogCommonSymbol, LogEvent } from '@travetto/log';
37
+ import { type LogFormatter, LogCommonSymbol, type LogEvent } from '@travetto/log';
38
38
 
39
39
  @Injectable(LogCommonSymbol)
40
40
  export class SampleFormatter implements LogFormatter {
@@ -94,7 +94,7 @@ The [LogEvent](https://github.com/travetto/travetto/tree/main/module/log/src/typ
94
94
  **Code: Custom Logger**
95
95
  ```typescript
96
96
  import { Injectable } from '@travetto/di';
97
- import { LogEvent, Logger } from '@travetto/log';
97
+ import type { LogEvent, Logger } from '@travetto/log';
98
98
 
99
99
  @Injectable()
100
100
  export class CustomLogger implements Logger {
@@ -122,7 +122,7 @@ export interface LogDecorator {
122
122
  import os from 'node:os';
123
123
 
124
124
  import { Injectable } from '@travetto/di';
125
- import { LogDecorator, LogEvent } from '@travetto/log';
125
+ import type { LogDecorator, LogEvent } from '@travetto/log';
126
126
 
127
127
  @Injectable()
128
128
  export class CustomDecorator implements LogDecorator {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/log",
3
- "version": "7.0.4",
3
+ "version": "7.0.6",
4
4
  "type": "module",
5
5
  "description": "Logging framework that integrates at the console.log level.",
6
6
  "keywords": [
@@ -24,9 +24,9 @@
24
24
  "directory": "module/log"
25
25
  },
26
26
  "dependencies": {
27
- "@travetto/config": "^7.0.4",
28
- "@travetto/di": "^7.0.4",
29
- "@travetto/terminal": "^7.0.3"
27
+ "@travetto/config": "^7.0.6",
28
+ "@travetto/di": "^7.0.6",
29
+ "@travetto/terminal": "^7.0.5"
30
30
  },
31
31
  "travetto": {
32
32
  "displayName": "Logging"
@@ -1,7 +1,7 @@
1
1
  import { Injectable } from '@travetto/di';
2
2
  import { Config } from '@travetto/config';
3
3
 
4
- import { LogAppender, LogEvent } from '../types.ts';
4
+ import type { LogAppender, LogEvent } from '../types.ts';
5
5
 
6
6
  @Config('log')
7
7
  export class ConsoleLogAppenderConfig {
@@ -1,11 +1,11 @@
1
- import { createWriteStream, WriteStream, mkdirSync, openSync, appendFileSync } from 'node:fs';
1
+ import { createWriteStream, type WriteStream, mkdirSync, openSync, appendFileSync } from 'node:fs';
2
2
  import path from 'node:path';
3
3
 
4
4
  import { Env, Runtime } from '@travetto/runtime';
5
5
  import { Injectable } from '@travetto/di';
6
6
  import { Config, EnvVar } from '@travetto/config';
7
7
 
8
- import { LogAppender, LogEvent } from '../types.ts';
8
+ import type { LogAppender, LogEvent } from '../types.ts';
9
9
 
10
10
  @Config('log')
11
11
  export class FileLogAppenderConfig {
package/src/common.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Class, Env } from '@travetto/runtime';
1
+ import { type Class, Env } from '@travetto/runtime';
2
2
  import { Config, EnvVar } from '@travetto/config';
3
3
  import { DependencyRegistryIndex, Inject, Injectable } from '@travetto/di';
4
4
  import { Required } from '@travetto/schema';
@@ -7,7 +7,7 @@ import { ConsoleLogAppender } from './appender/console.ts';
7
7
  import { FileLogAppender } from './appender/file.ts';
8
8
  import { JsonLogFormatter } from './formatter/json.ts';
9
9
  import { LineLogFormatter } from './formatter/line.ts';
10
- import { LogAppender, LogFormatter, LogEvent, LogCommonSymbol, Logger } from './types.ts';
10
+ import { type LogAppender, type LogFormatter, type LogEvent, LogCommonSymbol, type Logger } from './types.ts';
11
11
 
12
12
  @Config('log')
13
13
  export class CommonLoggerConfig {
@@ -1,6 +1,6 @@
1
1
  import { Injectable } from '@travetto/di';
2
2
 
3
- import { LogFormatter, LogEvent } from '../types.ts';
3
+ import type { LogFormatter, LogEvent } from '../types.ts';
4
4
  import { LogFormatUtil } from './util.ts';
5
5
 
6
6
  /**
@@ -1,7 +1,7 @@
1
1
  import { Injectable } from '@travetto/di';
2
2
  import { Config } from '@travetto/config';
3
3
 
4
- import { LogEvent, LogFormatter } from '../types.ts';
4
+ import type { LogEvent, LogFormatter } from '../types.ts';
5
5
  import { LogFormatUtil } from './util.ts';
6
6
 
7
7
  @Config('log')
@@ -4,22 +4,24 @@ import { Env } from '@travetto/runtime';
4
4
  import { Injectable } from '@travetto/di';
5
5
  import { Config, EnvVar } from '@travetto/config';
6
6
  import { Ignore } from '@travetto/schema';
7
- import { StyleUtil } from '@travetto/terminal';
7
+ import { StyleUtil, type TermStyleFn } from '@travetto/terminal';
8
8
 
9
- import { LogEvent, LogFormatter } from '../types.ts';
9
+ import type { LogEvent, LogFormatter } from '../types.ts';
10
10
  import { LogFormatUtil } from './util.ts';
11
11
 
12
- /**
13
- * Level coloring
14
- */
15
- export const STYLES = StyleUtil.getPalette({
12
+ const styleInput = {
16
13
  info: ['#ffff00', '#ff5733'], // Yellow / goldenrod
17
14
  debug: ['#d3d3d3', '#555555'], // Light gray / dark gray
18
15
  warn: ['#ff8c00', '#ff00ff'], // Dark orange / bright magenta
19
16
  error: ['#8b0000', { text: '#00ffff', inverse: true }], // Dark red / bright cyan inverted
20
17
  timestamp: ['#e5e5e5', '#000000'], // White /black
21
18
  location: ['#add8e6', '#800080'] // Light blue / purple
22
- });
19
+ } as const;
20
+
21
+ /**
22
+ * Level coloring
23
+ */
24
+ export const STYLES: Record<keyof typeof styleInput, TermStyleFn> = StyleUtil.getPalette(styleInput);
23
25
 
24
26
  /**
25
27
  * Line formatting options
@@ -3,7 +3,7 @@ import { inspect, type InspectOptions } from 'node:util';
3
3
  import { DataUtil } from '@travetto/schema';
4
4
  import { safeAssign } from '@travetto/runtime';
5
5
 
6
- import { LogEvent } from '../types.ts';
6
+ import type { LogEvent } from '../types.ts';
7
7
 
8
8
  const INSPECT_OPTIONS = { colors: false, showHidden: false, depth: 5, breakLength: 200 };
9
9
 
package/src/service.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { ConsoleListener, ConsoleManager, ConsoleEvent, toConcrete } from '@travetto/runtime';
1
+ import { type ConsoleListener, ConsoleManager, type ConsoleEvent, toConcrete } from '@travetto/runtime';
2
2
  import { DependencyRegistryIndex, Injectable } from '@travetto/di';
3
3
 
4
- import { LogDecorator, LogEvent, Logger } from './types.ts';
4
+ import type { LogDecorator, LogEvent, Logger } from './types.ts';
5
5
  import { CommonLogger } from './common.ts';
6
6
 
7
7
  /**
package/src/types.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ConsoleEvent } from '@travetto/runtime';
1
+ import type { ConsoleEvent } from '@travetto/runtime';
2
2
 
3
3
  export const LogCommonSymbol = Symbol.for('@travetto/log:common');
4
4