@travetto/log 3.1.0-rc.1 → 3.1.0-rc.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/README.md +3 -0
- package/package.json +2 -2
- package/src/common.ts +7 -0
- package/src/service.ts +3 -1
package/README.md
CHANGED
|
@@ -93,6 +93,9 @@ The main caveat that comes with this, is that not all objects can be converted t
|
|
|
93
93
|
**Code: Standard Logging Config**
|
|
94
94
|
```typescript
|
|
95
95
|
export class CommonLoggerConfig {
|
|
96
|
+
@EnvVar('TRV_LOG_COMMON')
|
|
97
|
+
commonActive?: boolean;
|
|
98
|
+
|
|
96
99
|
/** Should we enrich the console by default */
|
|
97
100
|
@EnvVar('TRV_LOG_FORMAT')
|
|
98
101
|
format: 'line' | 'json' = 'line';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/log",
|
|
3
|
-
"version": "3.1.0-rc.
|
|
3
|
+
"version": "3.1.0-rc.2",
|
|
4
4
|
"description": "Logging framework that integrates at the console.log level.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"directory": "module/log"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@travetto/config": "^3.1.0-rc.
|
|
26
|
+
"@travetto/config": "^3.1.0-rc.2",
|
|
27
27
|
"@travetto/di": "^3.1.0-rc.0",
|
|
28
28
|
"@travetto/terminal": "^3.1.0-rc.0"
|
|
29
29
|
},
|
package/src/common.ts
CHANGED
|
@@ -12,6 +12,9 @@ import { Appender, Formatter, LogEvent } from './types';
|
|
|
12
12
|
|
|
13
13
|
@Config('log')
|
|
14
14
|
export class CommonLoggerConfig {
|
|
15
|
+
@EnvVar('TRV_LOG_COMMON')
|
|
16
|
+
commonActive?: boolean;
|
|
17
|
+
|
|
15
18
|
/** Should we enrich the console by default */
|
|
16
19
|
@EnvVar('TRV_LOG_FORMAT')
|
|
17
20
|
format: 'line' | 'json' = 'line';
|
|
@@ -47,6 +50,10 @@ export class CommonLogger {
|
|
|
47
50
|
@Inject()
|
|
48
51
|
config: CommonLoggerConfig;
|
|
49
52
|
|
|
53
|
+
get active(): boolean {
|
|
54
|
+
return this.config.commonActive !== false;
|
|
55
|
+
}
|
|
56
|
+
|
|
50
57
|
postConstruct(): void {
|
|
51
58
|
this.#formatter = this.config.format === 'line' ?
|
|
52
59
|
new LineFormatter(this.config) :
|
package/src/service.ts
CHANGED
|
@@ -21,7 +21,9 @@ export class LogService implements ConsoleListener, AutoCreate {
|
|
|
21
21
|
await GlobalTerminal.init();
|
|
22
22
|
|
|
23
23
|
const def = await DependencyRegistry.getInstance(CommonLogger);
|
|
24
|
-
|
|
24
|
+
if (def.active) {
|
|
25
|
+
this.#listeners.push(def);
|
|
26
|
+
}
|
|
25
27
|
|
|
26
28
|
const loggers = DependencyRegistry.getCandidateTypes(LoggerTarget);
|
|
27
29
|
const instances = await Promise.all(loggers.map(l => DependencyRegistry.getInstance<Logger>(l.class, l.qualifier)));
|