@enhanced-dom/logging 0.0.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/LICENSE.md +21 -0
- package/README.md +58 -0
- package/index.d.ts +5 -0
- package/index.js +5 -0
- package/logging.collector.d.ts +16 -0
- package/logging.collector.js +61 -0
- package/logging.console.d.ts +25 -0
- package/logging.console.js +88 -0
- package/logging.consumers.d.ts +3 -0
- package/logging.consumers.js +7 -0
- package/logging.stream.d.ts +8 -0
- package/logging.stream.js +31 -0
- package/logging.types.d.ts +44 -0
- package/logging.types.js +19 -0
- package/package.json +28 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023-present CD9B4A105290E17E0948E021DF4105107C88693C59C0B891CCC08366C51AEA990902A6A156AC87D88A2FC41422A5E1C3C4071F251F19441C4516000EC25F87DF
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
TL;DR;
|
|
2
|
+
|
|
3
|
+
Helpers for structured logging.
|
|
4
|
+
|
|
5
|
+
# What?
|
|
6
|
+
|
|
7
|
+
In many occasions we like to 'log' to multiple streams (e.g. console, analytics server, error server, etc.). Some of these streams are interested in some messages, others in completely different messages. This code has a log collector (fancy name for a list of messages) that can be flushed in 1 go to send logs to various streams. By default a console stream is implemented
|
|
8
|
+
|
|
9
|
+
# Why?
|
|
10
|
+
|
|
11
|
+
There seems to be a gap between a 'common' logging interface and the ability to inject consumers and 'collect' logs over a certain scope while staying within the app. Ideally, we'd like to:
|
|
12
|
+
|
|
13
|
+
- add different consumers, with the ability to filter the messages to send each consumer
|
|
14
|
+
- categorise the messages (by various tags)
|
|
15
|
+
- retain an entire messages 'session' (regardless of their 'importance') and capture it completely on e.g. an error
|
|
16
|
+
- be able to do some aggregations (wrt to perf) - similar to what `Logstash` can do (without having to use external apps ofc)
|
|
17
|
+
- expose a contextualized logger for inner context (i.e. function F1 calls F2, and F2 logs a message. F1 would like to 'set some context = tags' on the message logged from F2 without F2 knowing)
|
|
18
|
+
|
|
19
|
+
# How does this look like in practice?
|
|
20
|
+
|
|
21
|
+
**src/paymentHandlers.ts**
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { CollectorLogger, LogTagType, LogLevel } from '@enhanced-dom/logging'
|
|
25
|
+
const logger = new CollectorLogger('my unique id for a list of logs', { [LogTagType.Area]: 'payments' })
|
|
26
|
+
const acceptBalanceInquiry = (balanceInquiry: SimpleBalanceInquiry | ComplicatedBalanceInquiry) => {
|
|
27
|
+
enhancedLogger = logger.withTags({ [LogTagType.Procedure]: 'balance inquiry flow' })
|
|
28
|
+
logger.log()
|
|
29
|
+
if (validateBalanceInquiry(paymentInquiry, enhancedLogger)) {
|
|
30
|
+
processBalanceInquiry(paymentInquiry, enhancedLogger)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const validateBalanceInquiry = (balanceInquiry: SimpleBalanceInquiry | ComplicatedBalanceInquiry, enhancedLogger?: ILogger) => {
|
|
35
|
+
const validationLogger = enhancedLogger?.withTags({
|
|
36
|
+
[LogTagType.Step]: 'validation',
|
|
37
|
+
[LogTagType.Entity]: balanceInquiry.type,
|
|
38
|
+
[LogTagType.Id]: balanceInquiry.id,
|
|
39
|
+
})
|
|
40
|
+
validationLogger?.log({ stage: 'start' }, { [LogTagType.Level]: LogLevel.Perf }, 'Starting validation')
|
|
41
|
+
/// validation code
|
|
42
|
+
validationLogger?.log({ stage: 'end' }, { [LogTagType.Level]: LogLevel.Perf }, 'Ended validation')
|
|
43
|
+
return true
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const processBalanceInquiry = (balanceInquiry: SimpleBalanceInquiry | ComplicatedBalanceInquiry, enhancedLogger?: ILogger) => {
|
|
47
|
+
const processLogger = enhancedLogger?.withTags({
|
|
48
|
+
[LogTagType.Step]: 'process',
|
|
49
|
+
[LogTagType.Entity]: balanceInquiry.type,
|
|
50
|
+
[type: LogTagType.Id]: balanceInquiry.id
|
|
51
|
+
})
|
|
52
|
+
validationLogger?.log({ stage: 'start' }, { [LogTagType.Level]: LogLevel.Perf }, 'Starting processing')
|
|
53
|
+
/// process
|
|
54
|
+
validationLogger?.log({ stage: 'end' }, { [LogTagType.Level]: LogLevel.Perf }, 'Ended processing')
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Of course, this 'passing of logger through props' is not so ideal. One could do a service locator-like pattern where the right logger instance for a 'session id' is returned, but this fails short as soon as the tags need to be changed for the 'child' scope. In a tree-like context, one can access the parent contexts (e.g. dom nodes) to figure out which logger instance to use. This is much harder without binding the current execution to a global tree-like structure.
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ILogConsumerType, ILogEntry, ILogger, ILoggingSession } from './logging.types';
|
|
2
|
+
export declare class CollectorLogger implements ILogger {
|
|
3
|
+
protected _tags: ILoggingSession['tags'];
|
|
4
|
+
protected _consumers: Record<string, ILogConsumerType>;
|
|
5
|
+
protected _session: ILoggingSession;
|
|
6
|
+
protected _sessionsRepository: Record<string, ILoggingSession>;
|
|
7
|
+
constructor(sessionId?: string, tags?: ILoggingSession['tags'], consumersRegistry?: Record<string, ILogConsumerType>, sessionsRepository?: Record<string, ILoggingSession>);
|
|
8
|
+
log(...args: [ILogEntry['params']] | [ILogEntry['params'], ILogEntry['tags'], ILogEntry['message']] | [ILogEntry['params'], ILogEntry['message']]): void;
|
|
9
|
+
withTags(tags: ILogEntry['tags']): ILogger;
|
|
10
|
+
flush(): void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Flushing at the end of the log is nice, but in case we have some sort of unhandled exception,
|
|
14
|
+
* we should be able to flush all the logs in progress
|
|
15
|
+
*/
|
|
16
|
+
export declare const flushAllOutstandingSessions: () => void;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import uniqueId from 'lodash.uniqueid';
|
|
2
|
+
import { defaultConsumers } from './logging.consumers';
|
|
3
|
+
const defaultSessionsRepository = {};
|
|
4
|
+
export class CollectorLogger {
|
|
5
|
+
constructor(sessionId, tags = {}, consumersRegistry, sessionsRepository) {
|
|
6
|
+
this._tags = {};
|
|
7
|
+
this._consumers = defaultConsumers;
|
|
8
|
+
this._sessionsRepository = defaultSessionsRepository;
|
|
9
|
+
const id = sessionId !== null && sessionId !== void 0 ? sessionId : uniqueId('logging-session-');
|
|
10
|
+
this._consumers = consumersRegistry !== null && consumersRegistry !== void 0 ? consumersRegistry : this._consumers;
|
|
11
|
+
this._sessionsRepository = sessionsRepository !== null && sessionsRepository !== void 0 ? sessionsRepository : this._sessionsRepository;
|
|
12
|
+
if (!this._sessionsRepository[id]) {
|
|
13
|
+
this._sessionsRepository[id] = {
|
|
14
|
+
id,
|
|
15
|
+
tags,
|
|
16
|
+
entries: [],
|
|
17
|
+
lastUpdatedOn: null,
|
|
18
|
+
createdOn: new Date(),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
this._tags = tags;
|
|
23
|
+
}
|
|
24
|
+
this._session = this._sessionsRepository[id];
|
|
25
|
+
}
|
|
26
|
+
log(...args) {
|
|
27
|
+
const params = args[0];
|
|
28
|
+
let tags = {};
|
|
29
|
+
let message = undefined;
|
|
30
|
+
if (args.length > 2) {
|
|
31
|
+
tags = args[1];
|
|
32
|
+
message = args[2];
|
|
33
|
+
}
|
|
34
|
+
else if (args.length > 1) {
|
|
35
|
+
message = args[1];
|
|
36
|
+
}
|
|
37
|
+
this._session.entries.push({
|
|
38
|
+
params,
|
|
39
|
+
message,
|
|
40
|
+
tags,
|
|
41
|
+
createdOn: new Date(),
|
|
42
|
+
});
|
|
43
|
+
this._session.lastUpdatedOn = new Date();
|
|
44
|
+
}
|
|
45
|
+
withTags(tags) {
|
|
46
|
+
return new CollectorLogger(this._session.id, { ...this._tags, ...tags }, this._consumers, this._sessionsRepository);
|
|
47
|
+
}
|
|
48
|
+
flush() {
|
|
49
|
+
Object.values(this._consumers).forEach((consumer) => { var _a; return (_a = consumer.session) === null || _a === void 0 ? void 0 : _a.call(consumer, this._session); });
|
|
50
|
+
delete this._sessionsRepository[this._session.id];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Flushing at the end of the log is nice, but in case we have some sort of unhandled exception,
|
|
55
|
+
* we should be able to flush all the logs in progress
|
|
56
|
+
*/
|
|
57
|
+
export const flushAllOutstandingSessions = () => {
|
|
58
|
+
Object.values(defaultSessionsRepository)
|
|
59
|
+
.sort((s1, s2) => (s1.createdOn.valueOf() < s2.createdOn.valueOf() ? -1 : 1))
|
|
60
|
+
.forEach((session) => Object.values(defaultConsumers).forEach((consumer) => { var _a; return (_a = consumer.session) === null || _a === void 0 ? void 0 : _a.call(consumer, session); }));
|
|
61
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ILogEntry, ILoggingSession } from './logging.types';
|
|
2
|
+
export declare const levelClearsTreshold: (tresholdLevel: string, evaluatedLevel?: string) => boolean;
|
|
3
|
+
export declare const getEntryLevel: (entry: ILogEntry) => string;
|
|
4
|
+
declare let defaultConfig: {
|
|
5
|
+
level: any;
|
|
6
|
+
sessionFilter: (session: ILoggingSession) => boolean;
|
|
7
|
+
entryFilter: (entries: ILogEntry[]) => ILogEntry[];
|
|
8
|
+
sessionSerializer: (session: ILoggingSession) => string;
|
|
9
|
+
entrySerializer: (entry: ILogEntry) => string;
|
|
10
|
+
};
|
|
11
|
+
export declare const defaultLookbackEntrySelector: (entries: ILogEntry[]) => ILogEntry[];
|
|
12
|
+
export declare const defaultPerformanceEntryCompactor: (entries: ILogEntry[]) => ILogEntry[];
|
|
13
|
+
export declare const defaultConsoleConsumer: {
|
|
14
|
+
session: (session: ILoggingSession) => void;
|
|
15
|
+
entry: (entry: ILogEntry) => void;
|
|
16
|
+
};
|
|
17
|
+
export declare const configureDefaultConsoleConsumer: (config: Partial<typeof defaultConfig>) => void;
|
|
18
|
+
export declare const getDefaultConsoleConsumerConfig: () => {
|
|
19
|
+
level: any;
|
|
20
|
+
sessionFilter: (session: ILoggingSession) => boolean;
|
|
21
|
+
entryFilter: (entries: ILogEntry[]) => ILogEntry[];
|
|
22
|
+
sessionSerializer: (session: ILoggingSession) => string;
|
|
23
|
+
entrySerializer: (entry: ILogEntry) => string;
|
|
24
|
+
};
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import omit from 'lodash.omit';
|
|
2
|
+
import zip from 'lodash.zip';
|
|
3
|
+
import { LogLevel, LogTagType } from './logging.types';
|
|
4
|
+
export const levelClearsTreshold = (tresholdLevel, evaluatedLevel) => {
|
|
5
|
+
switch (tresholdLevel) {
|
|
6
|
+
case LogLevel.Fatal:
|
|
7
|
+
return evaluatedLevel === LogLevel.Fatal;
|
|
8
|
+
case LogLevel.Critical:
|
|
9
|
+
return [LogLevel.Fatal, LogLevel.Critical].includes(evaluatedLevel);
|
|
10
|
+
case LogLevel.Error:
|
|
11
|
+
return [LogLevel.Fatal, LogLevel.Critical, LogLevel.Error].includes(evaluatedLevel);
|
|
12
|
+
case LogLevel.Warning:
|
|
13
|
+
return [LogLevel.Fatal, LogLevel.Critical, LogLevel.Error, LogLevel.Warning].includes(evaluatedLevel);
|
|
14
|
+
case LogLevel.Performance:
|
|
15
|
+
return [LogLevel.Fatal, LogLevel.Critical, LogLevel.Error, LogLevel.Warning, LogLevel.Performance].includes(evaluatedLevel);
|
|
16
|
+
case LogLevel.Info:
|
|
17
|
+
return [LogLevel.Fatal, LogLevel.Critical, LogLevel.Error, LogLevel.Warning, LogLevel.Performance, LogLevel.Info].includes(evaluatedLevel);
|
|
18
|
+
default:
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
export const getEntryLevel = (entry) => {
|
|
23
|
+
return entry.tags[LogTagType.Level];
|
|
24
|
+
};
|
|
25
|
+
let defaultConfig = Object.freeze({
|
|
26
|
+
level: LogLevel.Error,
|
|
27
|
+
sessionFilter: () => true,
|
|
28
|
+
entryFilter: (entries) => entries.filter((e) => levelClearsTreshold(defaultConfig.level, getEntryLevel(e))),
|
|
29
|
+
sessionSerializer: (session) => {
|
|
30
|
+
const listOfFormattedEntries = zip(new Array(session.entries.length - 1).fill('\t'), session.entries.map((e) => defaultConfig.entrySerializer(e)), new Array(session.entries.length - 1).fill('\n')).flatMap((a) => a.filter((e) => !!e));
|
|
31
|
+
return [`Log session with tags ${JSON.stringify(session.tags)}}:`, '\n', ...listOfFormattedEntries].join();
|
|
32
|
+
},
|
|
33
|
+
entrySerializer: (entry) => {
|
|
34
|
+
return `${entry.createdOn} | ${JSON.stringify(entry.tags)} | ${entry.message}`;
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
export const defaultLookbackEntrySelector = (entries) => {
|
|
38
|
+
const anyEntryClearsThreshold = entries.some((e) => levelClearsTreshold(defaultConfig.level, getEntryLevel(e)));
|
|
39
|
+
return anyEntryClearsThreshold ? entries : [];
|
|
40
|
+
};
|
|
41
|
+
export const defaultPerformanceEntryCompactor = (entries) => {
|
|
42
|
+
const performanceEndEntries = entries.filter((e) => e.tags[LogTagType.Level] === LogLevel.Performance && e.params.stage === 'end');
|
|
43
|
+
const performanceEntryPairs = performanceEndEntries.map((endEntry) => [
|
|
44
|
+
entries.find((possibleStartEntry) => possibleStartEntry.params.stage === 'start' && JSON.stringify(endEntry.tags) == JSON.stringify(possibleStartEntry.tags)),
|
|
45
|
+
endEntry,
|
|
46
|
+
]);
|
|
47
|
+
const entryPairsToCompact = performanceEntryPairs.filter(([startEntry]) => !!startEntry);
|
|
48
|
+
if (!entryPairsToCompact) {
|
|
49
|
+
return entries;
|
|
50
|
+
}
|
|
51
|
+
const compactedEntries = [...entries];
|
|
52
|
+
entryPairsToCompact.forEach(([startEntry, endEntry]) => {
|
|
53
|
+
compactedEntries.splice(compactedEntries.indexOf(endEntry), 1, {
|
|
54
|
+
tags: startEntry.tags,
|
|
55
|
+
createdOn: endEntry.createdOn,
|
|
56
|
+
params: omit({ ...startEntry.params, elapsed: endEntry.createdOn.valueOf() - startEntry.createdOn.valueOf(), ...endEntry.params }, [
|
|
57
|
+
'stage',
|
|
58
|
+
]),
|
|
59
|
+
message: 'Performance calculation',
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
return compactedEntries;
|
|
63
|
+
};
|
|
64
|
+
export const defaultConsoleConsumer = {
|
|
65
|
+
session: (session) => {
|
|
66
|
+
if (!defaultConfig.sessionFilter(session)) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const entriesToShow = defaultConfig.entryFilter(session.entries);
|
|
70
|
+
if (!entriesToShow.length) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
console.log(defaultConfig.sessionSerializer({ ...session, entries: entriesToShow }));
|
|
74
|
+
},
|
|
75
|
+
entry: (entry) => {
|
|
76
|
+
const entriesToShow = defaultConfig.entryFilter([entry]);
|
|
77
|
+
if (!entriesToShow.length) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
console.log(defaultConfig.entrySerializer(entry));
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
export const configureDefaultConsoleConsumer = (config) => {
|
|
84
|
+
defaultConfig = Object.freeze({ ...defaultConfig, ...config });
|
|
85
|
+
};
|
|
86
|
+
export const getDefaultConsoleConsumerConfig = () => {
|
|
87
|
+
return defaultConfig;
|
|
88
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ILogConsumerType, ILogEntry, ILogger, ILoggingSession } from './logging.types';
|
|
2
|
+
export declare class StreamingLogger implements ILogger {
|
|
3
|
+
protected _tags: ILoggingSession['tags'];
|
|
4
|
+
protected _consumers: Record<string, ILogConsumerType>;
|
|
5
|
+
constructor(tags?: ILoggingSession['tags'], consumers?: Record<string, ILogConsumerType>);
|
|
6
|
+
log(...args: [ILogEntry['params']] | [ILogEntry['params'], ILogEntry['tags'], ILogEntry['message']] | [ILogEntry['params'], ILogEntry['message']]): void;
|
|
7
|
+
withTags(tags: ILogEntry['tags']): ILogger;
|
|
8
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { defaultConsumers } from './logging.consumers';
|
|
2
|
+
export class StreamingLogger {
|
|
3
|
+
constructor(tags = {}, consumers = defaultConsumers) {
|
|
4
|
+
this._tags = {};
|
|
5
|
+
this._consumers = {};
|
|
6
|
+
this._tags = tags;
|
|
7
|
+
this._consumers = consumers;
|
|
8
|
+
}
|
|
9
|
+
log(...args) {
|
|
10
|
+
const params = args[0];
|
|
11
|
+
let tags = {};
|
|
12
|
+
let message = undefined;
|
|
13
|
+
if (args.length > 2) {
|
|
14
|
+
tags = args[1];
|
|
15
|
+
message = args[2];
|
|
16
|
+
}
|
|
17
|
+
else if (args.length > 1) {
|
|
18
|
+
message = args[1];
|
|
19
|
+
}
|
|
20
|
+
const logMessage = {
|
|
21
|
+
params,
|
|
22
|
+
message,
|
|
23
|
+
tags: { ...this._tags, ...tags },
|
|
24
|
+
createdOn: new Date(),
|
|
25
|
+
};
|
|
26
|
+
Object.values(this._consumers).forEach((consumer) => { var _a; return (_a = consumer.entry) === null || _a === void 0 ? void 0 : _a.call(consumer, logMessage); });
|
|
27
|
+
}
|
|
28
|
+
withTags(tags) {
|
|
29
|
+
return new StreamingLogger({ ...this._tags, ...tags }, this._consumers);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export interface ILogEntry {
|
|
2
|
+
createdOn: Date;
|
|
3
|
+
params: Record<string, any>;
|
|
4
|
+
message?: string;
|
|
5
|
+
tags: Record<string, string>;
|
|
6
|
+
}
|
|
7
|
+
export interface ILoggingSession {
|
|
8
|
+
id: string;
|
|
9
|
+
createdOn: Date;
|
|
10
|
+
lastUpdatedOn: Date;
|
|
11
|
+
entries: ILogEntry[];
|
|
12
|
+
tags: Record<string, string>;
|
|
13
|
+
}
|
|
14
|
+
export interface ILogger {
|
|
15
|
+
log(...args: [ILogEntry['params'], ILogEntry['tags'], ILogEntry['message']]): void;
|
|
16
|
+
log(...args: [ILogEntry['params'], ILogEntry['message']]): void;
|
|
17
|
+
log(...args: [ILogEntry['params']]): void;
|
|
18
|
+
withTags(tags: ILogEntry['tags']): ILogger;
|
|
19
|
+
flush?: () => void;
|
|
20
|
+
}
|
|
21
|
+
export declare enum LogTagType {
|
|
22
|
+
Level = "level",
|
|
23
|
+
Entity = "entity",
|
|
24
|
+
Id = "id",
|
|
25
|
+
Area = "area",
|
|
26
|
+
Procedure = "procedure",
|
|
27
|
+
Step = "step"
|
|
28
|
+
}
|
|
29
|
+
export declare enum LogLevel {
|
|
30
|
+
Fatal = "fatal",
|
|
31
|
+
Critical = "critical",
|
|
32
|
+
Error = "error",
|
|
33
|
+
Warning = "warn",
|
|
34
|
+
Performance = "perf",
|
|
35
|
+
Info = "info",
|
|
36
|
+
Debug = "debug"
|
|
37
|
+
}
|
|
38
|
+
export type ILogConsumerType = {
|
|
39
|
+
session: (session: ILoggingSession) => void;
|
|
40
|
+
entry?: (entry: ILogEntry) => void;
|
|
41
|
+
} | {
|
|
42
|
+
session?: (session: ILoggingSession) => void;
|
|
43
|
+
entry: (entry: ILogEntry) => void;
|
|
44
|
+
};
|
package/logging.types.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export var LogTagType;
|
|
2
|
+
(function (LogTagType) {
|
|
3
|
+
LogTagType["Level"] = "level";
|
|
4
|
+
LogTagType["Entity"] = "entity";
|
|
5
|
+
LogTagType["Id"] = "id";
|
|
6
|
+
LogTagType["Area"] = "area";
|
|
7
|
+
LogTagType["Procedure"] = "procedure";
|
|
8
|
+
LogTagType["Step"] = "step";
|
|
9
|
+
})(LogTagType || (LogTagType = {}));
|
|
10
|
+
export var LogLevel;
|
|
11
|
+
(function (LogLevel) {
|
|
12
|
+
LogLevel["Fatal"] = "fatal";
|
|
13
|
+
LogLevel["Critical"] = "critical";
|
|
14
|
+
LogLevel["Error"] = "error";
|
|
15
|
+
LogLevel["Warning"] = "warn";
|
|
16
|
+
LogLevel["Performance"] = "perf";
|
|
17
|
+
LogLevel["Info"] = "info";
|
|
18
|
+
LogLevel["Debug"] = "debug";
|
|
19
|
+
})(LogLevel || (LogLevel = {}));
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@enhanced-dom/logging",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Helpers for basic logging",
|
|
5
|
+
"repository": "https://github.com/enhanced-dom/logging.git",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"keywords": [],
|
|
8
|
+
"author": "CD9B4A105290E17E0948E021DF4105107C88693C59C0B891CCC08366C51AEA990902A6A156AC87D88A2FC41422A5E1C3C4071F251F19441C4516000EC25F87DF",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"lodash.zip": "^4.2.0",
|
|
12
|
+
"lodash.omit": "^4.5.0",
|
|
13
|
+
"lodash.uniqueid": "^4.0.1"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@enhanced-dom/build": "^0.0.2",
|
|
17
|
+
"@enhanced-dom/lint": "^0.0.9",
|
|
18
|
+
"@enhanced-dom/jest": "^0.0.1",
|
|
19
|
+
"@types/lodash.omit": "^4.5.7",
|
|
20
|
+
"@types/lodash.uniqueid": "^4.0.7",
|
|
21
|
+
"@types/lodash.zip": "^4.2.7",
|
|
22
|
+
"typescript": "^4.9.4"
|
|
23
|
+
},
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=14.17.0",
|
|
26
|
+
"npm": ">=9.0.0"
|
|
27
|
+
}
|
|
28
|
+
}
|