@4players/odin-common 2.4.3 → 2.4.4
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/lib/cjs/utility/log.js +25 -3
- package/lib/esm/utility/log.js +23 -2
- package/lib/utility/log.d.ts +17 -5
- package/package.json +1 -1
package/lib/cjs/utility/log.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.log = exports.OdinError = void 0;
|
|
3
|
+
exports.Logger = exports.log = exports.OdinError = void 0;
|
|
4
4
|
class OdinError extends Error {
|
|
5
5
|
constructor(message = '', options) {
|
|
6
6
|
super(message);
|
|
@@ -33,8 +33,8 @@ function log(message, options, filters = { projects: [], kind: [] }) {
|
|
|
33
33
|
}
|
|
34
34
|
logMessage += ` at ${options === null || options === void 0 ? void 0 : options.project} ${hours}:${minutes}:${seconds}\n`;
|
|
35
35
|
logMessage += `${message}\n`;
|
|
36
|
-
if (options.
|
|
37
|
-
console[options.
|
|
36
|
+
if (options.type) {
|
|
37
|
+
console[options.type](logMessage);
|
|
38
38
|
}
|
|
39
39
|
else {
|
|
40
40
|
console.log(logMessage);
|
|
@@ -45,3 +45,25 @@ function log(message, options, filters = { projects: [], kind: [] }) {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
exports.log = log;
|
|
48
|
+
class Logger {
|
|
49
|
+
constructor(project, filters) {
|
|
50
|
+
this.project = project;
|
|
51
|
+
this.filters = filters;
|
|
52
|
+
}
|
|
53
|
+
log(message, kind) {
|
|
54
|
+
log('message', { project: this.project, kind, type: 'log' }, this.filters);
|
|
55
|
+
}
|
|
56
|
+
info(message, kind) {
|
|
57
|
+
log('message', { project: this.project, kind, type: 'info' }, this.filters);
|
|
58
|
+
}
|
|
59
|
+
error(message, kind) {
|
|
60
|
+
log('message', { project: this.project, kind, type: 'error' }, this.filters);
|
|
61
|
+
}
|
|
62
|
+
warn(message, kind) {
|
|
63
|
+
log('message', { project: this.project, kind, type: 'warn' }, this.filters);
|
|
64
|
+
}
|
|
65
|
+
debug(message, kind) {
|
|
66
|
+
log('message', { project: this.project, kind, type: 'debug' }, this.filters);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.Logger = Logger;
|
package/lib/esm/utility/log.js
CHANGED
|
@@ -29,8 +29,8 @@ export function log(message, options, filters = { projects: [], kind: [] }) {
|
|
|
29
29
|
}
|
|
30
30
|
logMessage += ` at ${options === null || options === void 0 ? void 0 : options.project} ${hours}:${minutes}:${seconds}\n`;
|
|
31
31
|
logMessage += `${message}\n`;
|
|
32
|
-
if (options.
|
|
33
|
-
console[options.
|
|
32
|
+
if (options.type) {
|
|
33
|
+
console[options.type](logMessage);
|
|
34
34
|
}
|
|
35
35
|
else {
|
|
36
36
|
console.log(logMessage);
|
|
@@ -40,3 +40,24 @@ export function log(message, options, filters = { projects: [], kind: [] }) {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
+
export class Logger {
|
|
44
|
+
constructor(project, filters) {
|
|
45
|
+
this.project = project;
|
|
46
|
+
this.filters = filters;
|
|
47
|
+
}
|
|
48
|
+
log(message, kind) {
|
|
49
|
+
log('message', { project: this.project, kind, type: 'log' }, this.filters);
|
|
50
|
+
}
|
|
51
|
+
info(message, kind) {
|
|
52
|
+
log('message', { project: this.project, kind, type: 'info' }, this.filters);
|
|
53
|
+
}
|
|
54
|
+
error(message, kind) {
|
|
55
|
+
log('message', { project: this.project, kind, type: 'error' }, this.filters);
|
|
56
|
+
}
|
|
57
|
+
warn(message, kind) {
|
|
58
|
+
log('message', { project: this.project, kind, type: 'warn' }, this.filters);
|
|
59
|
+
}
|
|
60
|
+
debug(message, kind) {
|
|
61
|
+
log('message', { project: this.project, kind, type: 'debug' }, this.filters);
|
|
62
|
+
}
|
|
63
|
+
}
|
package/lib/utility/log.d.ts
CHANGED
|
@@ -1,14 +1,26 @@
|
|
|
1
|
+
export type LogType = 'debug' | 'info' | 'warn' | 'error' | 'log';
|
|
1
2
|
export type LogOptions = {
|
|
2
3
|
kind: string;
|
|
3
4
|
project: string;
|
|
4
|
-
|
|
5
|
+
type?: LogType;
|
|
6
|
+
};
|
|
7
|
+
export type LogFilters = {
|
|
8
|
+
projects: [];
|
|
9
|
+
kind: [];
|
|
5
10
|
};
|
|
6
11
|
export declare class OdinError extends Error {
|
|
7
12
|
message: string;
|
|
8
13
|
readonly name = "OdinError";
|
|
9
14
|
constructor(message?: string, options?: LogOptions);
|
|
10
15
|
}
|
|
11
|
-
export declare function log(message: string, options: LogOptions, filters?:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
export declare function log(message: string, options: LogOptions, filters?: LogFilters): void;
|
|
17
|
+
export declare class Logger {
|
|
18
|
+
readonly project: string;
|
|
19
|
+
filters: LogFilters;
|
|
20
|
+
constructor(project: string, filters: LogFilters);
|
|
21
|
+
log(message: string, kind: string): void;
|
|
22
|
+
info(message: string, kind: string): void;
|
|
23
|
+
error(message: string, kind: string): void;
|
|
24
|
+
warn(message: string, kind: string): void;
|
|
25
|
+
debug(message: string, kind: string): void;
|
|
26
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@4players/odin-common",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.4",
|
|
4
4
|
"description": "A collection of commonly used type definitions and utility functions across ODIN web projects",
|
|
5
5
|
"author": "Josho Bleicker <josho.bleicker@4players.io> (https://www.4players.io)",
|
|
6
6
|
"homepage": "https://www.4players.io",
|