@travetto/log 8.0.0-alpha.0 → 8.0.0-alpha.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.
- package/package.json +4 -4
- package/src/appender/file.ts +3 -2
- package/src/common.ts +3 -2
- package/src/formatter/line.ts +3 -2
- package/src/service.ts +3 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/log",
|
|
3
|
-
"version": "8.0.0-alpha.
|
|
3
|
+
"version": "8.0.0-alpha.2",
|
|
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": "^8.0.0-alpha.
|
|
28
|
-
"@travetto/di": "^8.0.0-alpha.
|
|
29
|
-
"@travetto/terminal": "^8.0.0-alpha.
|
|
27
|
+
"@travetto/config": "^8.0.0-alpha.2",
|
|
28
|
+
"@travetto/di": "^8.0.0-alpha.2",
|
|
29
|
+
"@travetto/terminal": "^8.0.0-alpha.2"
|
|
30
30
|
},
|
|
31
31
|
"travetto": {
|
|
32
32
|
"displayName": "Logging"
|
package/src/appender/file.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { createWriteStream, type WriteStream, mkdirSync, openSync, appendFileSyn
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
|
|
4
4
|
import { Env, Runtime } from '@travetto/runtime';
|
|
5
|
-
import { Injectable } from '@travetto/di';
|
|
5
|
+
import { Injectable, PostConstruct } from '@travetto/di';
|
|
6
6
|
import { Config, EnvVar } from '@travetto/config';
|
|
7
7
|
|
|
8
8
|
import type { LogAppender, LogEvent } from '../types.ts';
|
|
@@ -14,7 +14,8 @@ export class FileLogAppenderConfig {
|
|
|
14
14
|
|
|
15
15
|
writeSync = false;
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
@PostConstruct()
|
|
18
|
+
finalizeConfig(): void {
|
|
18
19
|
if (!this.output || this.output === 'file' || this.output === 'console') {
|
|
19
20
|
this.output = Runtime.toolPath('@', 'output.log');
|
|
20
21
|
}
|
package/src/common.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Class, Env } from '@travetto/runtime';
|
|
2
2
|
import { Config, EnvVar } from '@travetto/config';
|
|
3
|
-
import { DependencyRegistryIndex, Inject, Injectable } from '@travetto/di';
|
|
3
|
+
import { DependencyRegistryIndex, Inject, Injectable, PostConstruct } from '@travetto/di';
|
|
4
4
|
import { Required } from '@travetto/schema';
|
|
5
5
|
|
|
6
6
|
import { ConsoleLogAppender } from './appender/console.ts';
|
|
@@ -32,7 +32,8 @@ export class CommonLogger implements Logger {
|
|
|
32
32
|
@Required(false)
|
|
33
33
|
appender: LogAppender;
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
@PostConstruct()
|
|
36
|
+
async initializeDependencies(): Promise<void> {
|
|
36
37
|
const formatterCls: Class = this.config.format === 'line' ? LineLogFormatter : JsonLogFormatter;
|
|
37
38
|
const appenderCls: Class = this.config.output !== 'console' ? FileLogAppender : ConsoleLogAppender;
|
|
38
39
|
this.formatter ??= await DependencyRegistryIndex.getInstance(formatterCls);
|
package/src/formatter/line.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import util from 'node:util';
|
|
2
2
|
|
|
3
3
|
import { Env, RuntimeIndex } from '@travetto/runtime';
|
|
4
|
-
import { Injectable } from '@travetto/di';
|
|
4
|
+
import { Injectable, PostConstruct } from '@travetto/di';
|
|
5
5
|
import { Config, EnvVar } from '@travetto/config';
|
|
6
6
|
import { Ignore } from '@travetto/schema';
|
|
7
7
|
import { StyleUtil, type TermStyleFn } from '@travetto/terminal';
|
|
@@ -59,7 +59,8 @@ export class LineLogFormatterConfig {
|
|
|
59
59
|
colors: boolean;
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
@PostConstruct()
|
|
63
|
+
finalizeConfig(): void {
|
|
63
64
|
this.time ??= (!this.plain ? 'ms' : undefined);
|
|
64
65
|
this.plain ??= !StyleUtil.enabled;
|
|
65
66
|
this.colorize ??= !this.plain;
|
package/src/service.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ConsoleListener, ConsoleManager, type ConsoleEvent, toConcrete } from '@travetto/runtime';
|
|
2
|
-
import { DependencyRegistryIndex, Injectable } from '@travetto/di';
|
|
2
|
+
import { DependencyRegistryIndex, Injectable, PostConstruct } from '@travetto/di';
|
|
3
3
|
|
|
4
4
|
import type { LogDecorator, LogEvent, Logger } from './types.ts';
|
|
5
5
|
import { CommonLogger } from './common.ts';
|
|
@@ -20,7 +20,8 @@ export class LogService implements ConsoleListener {
|
|
|
20
20
|
*/
|
|
21
21
|
#decorators: LogDecorator[] = [];
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
@PostConstruct()
|
|
24
|
+
async instrumentLogger(): Promise<void> {
|
|
24
25
|
this.#listeners = await DependencyRegistryIndex.getInstances(toConcrete<Logger>(), candidate => candidate.class !== CommonLogger);
|
|
25
26
|
if (!this.#listeners.length) {
|
|
26
27
|
this.#listeners = [await DependencyRegistryIndex.getInstance(CommonLogger)];
|