@push.rocks/smartlog 3.0.2 → 3.0.5
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/dist_bundle/bundle.js +42 -18
- package/dist_bundle/bundle.js.map +3 -3
- package/dist_ts/00_commitinfo_data.js +4 -4
- package/dist_ts/index.js +2 -2
- package/dist_ts/smartlog.classes.consolelog.js +2 -2
- package/dist_ts/smartlog.classes.loggroup.js +2 -2
- package/dist_ts/smartlog.classes.logrouter.d.ts +3 -3
- package/dist_ts/smartlog.classes.logrouter.js +2 -3
- package/dist_ts/smartlog.classes.smartlog.js +20 -22
- package/dist_ts/smartlog.plugins.d.ts +2 -2
- package/dist_ts/smartlog.plugins.js +3 -3
- package/npmextra.json +24 -5
- package/package.json +28 -20
- package/readme.hints.md +1 -0
- package/readme.md +86 -54
- package/ts/00_commitinfo_data.ts +3 -3
- package/ts/smartlog.classes.logrouter.ts +3 -5
- package/ts/smartlog.classes.smartlog.ts +19 -18
- package/ts/smartlog.plugins.ts +2 -2
package/dist_bundle/bundle.js
CHANGED
|
@@ -16,13 +16,17 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
20
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
21
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
22
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
19
23
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
20
24
|
mod
|
|
21
25
|
));
|
|
22
26
|
|
|
23
|
-
// node_modules/.pnpm/@
|
|
27
|
+
// node_modules/.pnpm/@push.rocks+isounique@1.0.5/node_modules/@push.rocks/isounique/dist_ts/index.js
|
|
24
28
|
var require_dist_ts = __commonJS({
|
|
25
|
-
"node_modules/.pnpm/@
|
|
29
|
+
"node_modules/.pnpm/@push.rocks+isounique@1.0.5/node_modules/@push.rocks/isounique/dist_ts/index.js"(exports) {
|
|
26
30
|
"use strict";
|
|
27
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
32
|
exports.uni = void 0;
|
|
@@ -50,11 +54,15 @@ var ConsoleLog = class {
|
|
|
50
54
|
// ts/smartlog.classes.logrouter.ts
|
|
51
55
|
var LogRouter = class {
|
|
52
56
|
constructor() {
|
|
57
|
+
/**
|
|
58
|
+
* all log destinations
|
|
59
|
+
*/
|
|
53
60
|
this.logDestinations = [];
|
|
54
61
|
}
|
|
55
62
|
addLogDestination(logDestination) {
|
|
56
63
|
this.logDestinations.push(logDestination);
|
|
57
64
|
}
|
|
65
|
+
// routes the log according to added logDestinations
|
|
58
66
|
async routeLog(logPackageArg) {
|
|
59
67
|
for (const logDestination of this.logDestinations) {
|
|
60
68
|
await logDestination.handleLog(logPackageArg);
|
|
@@ -73,37 +81,53 @@ var Smartlog = class {
|
|
|
73
81
|
addLogDestination(logDestinationArg) {
|
|
74
82
|
this.logRouter.addLogDestination(logDestinationArg);
|
|
75
83
|
}
|
|
84
|
+
// ============
|
|
85
|
+
// Logger Setup
|
|
86
|
+
// ============
|
|
87
|
+
/**
|
|
88
|
+
* enables console logging
|
|
89
|
+
*/
|
|
76
90
|
enableConsole(optionsArg) {
|
|
77
91
|
if (globalThis.process && optionsArg && optionsArg.captureAll) {
|
|
78
92
|
const process = globalThis.process;
|
|
79
|
-
const
|
|
93
|
+
const originalStdoutWrite = process.stdout.write.bind(process.stdout);
|
|
94
|
+
const originalStderrWrite = process.stderr.write.bind(process.stderr);
|
|
80
95
|
process.stdout.write = (...args) => {
|
|
81
96
|
const logString = args[0];
|
|
82
|
-
if (!logString || typeof logString
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
97
|
+
if (!logString || typeof logString !== "string") {
|
|
98
|
+
return originalStdoutWrite(...args);
|
|
99
|
+
}
|
|
100
|
+
if (!logString.startsWith("LOG")) {
|
|
101
|
+
if (logString.includes("Error:")) {
|
|
102
|
+
this.log("error", logString);
|
|
103
|
+
} else {
|
|
104
|
+
this.log("info", logString);
|
|
90
105
|
}
|
|
91
106
|
return true;
|
|
92
107
|
}
|
|
93
|
-
|
|
94
|
-
return true;
|
|
108
|
+
return originalStdoutWrite(...args);
|
|
95
109
|
};
|
|
96
110
|
process.stderr.write = (...args) => {
|
|
97
|
-
|
|
98
|
-
|
|
111
|
+
const logString = args[0];
|
|
112
|
+
if (!logString || typeof logString !== "string" || !logString.startsWith("LOG")) {
|
|
113
|
+
this.log("error", logString);
|
|
99
114
|
return true;
|
|
100
115
|
}
|
|
101
|
-
|
|
102
|
-
return true;
|
|
116
|
+
return originalStderrWrite(...args);
|
|
103
117
|
};
|
|
104
118
|
}
|
|
105
119
|
this.consoleEnabled = true;
|
|
106
120
|
}
|
|
121
|
+
// =============
|
|
122
|
+
// log functions
|
|
123
|
+
// =============
|
|
124
|
+
/**
|
|
125
|
+
* main log method
|
|
126
|
+
* @param logLevelArg - the log level
|
|
127
|
+
* @param logMessageArg - the log message
|
|
128
|
+
* @param logDataArg - any additional log data
|
|
129
|
+
* @param correlationArg - info about corrleations
|
|
130
|
+
*/
|
|
107
131
|
async log(logLevelArg, logMessageArg, logDataArg, correlationArg) {
|
|
108
132
|
correlationArg = {
|
|
109
133
|
...{
|
|
@@ -150,7 +174,7 @@ var Smartlog = class {
|
|
|
150
174
|
}
|
|
151
175
|
safeConsoleLog(logLine) {
|
|
152
176
|
console.log(
|
|
153
|
-
`LOG => ${new Date().getHours()}:${new Date().getMinutes()}:${new Date().getSeconds()} => ${logLine}`
|
|
177
|
+
`LOG => ${(/* @__PURE__ */ new Date()).getHours()}:${(/* @__PURE__ */ new Date()).getMinutes()}:${(/* @__PURE__ */ new Date()).getSeconds()} => ${logLine}`
|
|
154
178
|
);
|
|
155
179
|
}
|
|
156
180
|
createLogGroup(transactionId = "none") {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../node_modules/.pnpm/@
|
|
4
|
-
"sourcesContent": [null, "import * as isounique from '@
|
|
5
|
-
"mappings": "
|
|
3
|
+
"sources": ["../node_modules/.pnpm/@push.rocks+isounique@1.0.5/node_modules/@push.rocks/isounique/ts/index.ts", "../ts/smartlog.plugins.ts", "../ts/smartlog.classes.consolelog.ts", "../ts/smartlog.classes.logrouter.ts", "../ts/smartlog.classes.smartlog.ts", "../ts/smartlog.classes.loggroup.ts"],
|
|
4
|
+
"sourcesContent": [null, "import * as isounique from '@push.rocks/isounique';\nimport * as smartlogInterfaces from '@push.rocks/smartlog-interfaces';\n\nexport { isounique, smartlogInterfaces };\n", "import * as plugins from './smartlog.plugins.js';\n\n/**\n * a console log optimized for smartlog\n */\nexport class ConsoleLog {\n public log(\n logLevelArg: plugins.smartlogInterfaces.TLogLevel,\n logMessageArg: string,\n dataArg?: any,\n correlationArg?: plugins.smartlogInterfaces.ILogCorrelation\n ) {\n console.log(`__# ${logLevelArg}: ${logMessageArg}`);\n }\n}\n", "import * as plugins from './smartlog.plugins.js';\n\nexport class LogRouter {\n /**\n * all log destinations\n */\n private logDestinations: plugins.smartlogInterfaces.ILogDestination[] = [];\n\n constructor() {}\n\n public addLogDestination(logDestination: plugins.smartlogInterfaces.ILogDestination) {\n this.logDestinations.push(logDestination);\n }\n\n // routes the log according to added logDestinations\n public async routeLog(logPackageArg: plugins.smartlogInterfaces.ILogPackage) {\n for (const logDestination of this.logDestinations) {\n await logDestination.handleLog(logPackageArg);\n }\n }\n}\n", "import * as plugins from './smartlog.plugins.js';\n\nimport { LogRouter } from './smartlog.classes.logrouter.js';\nimport { LogGroup } from './smartlog.classes.loggroup.js';\n\nexport interface ISmartlogContructorOptions {\n logContext: plugins.smartlogInterfaces.ILogContext;\n minimumLogLevel?: plugins.smartlogInterfaces.TLogLevel;\n}\n\nexport class Smartlog implements plugins.smartlogInterfaces.ILogDestination {\n public logContext: plugins.smartlogInterfaces.ILogContext;\n public minimumLogLevel: plugins.smartlogInterfaces.TLogLevel;\n\n public uniInstanceId: string = plugins.isounique.uni();\n\n private consoleEnabled: boolean;\n\n private logRouter = new LogRouter();\n\n public addLogDestination(logDestinationArg: plugins.smartlogInterfaces.ILogDestination) {\n this.logRouter.addLogDestination(logDestinationArg);\n }\n\n constructor(optionsArg: ISmartlogContructorOptions) {\n this.logContext = optionsArg.logContext;\n this.minimumLogLevel = optionsArg.minimumLogLevel || 'silly';\n }\n\n // ============\n // Logger Setup\n // ============\n\n /**\n * enables console logging\n */\n public enableConsole(optionsArg?: { captureAll: boolean }) {\n if (globalThis.process && optionsArg && optionsArg.captureAll) {\n const process = globalThis.process;\n const originalStdoutWrite = process.stdout.write.bind(process.stdout);\n const originalStderrWrite = process.stderr.write.bind(process.stderr);\n\n process.stdout.write = (...args: any) => {\n const logString: string = args[0];\n if (!logString || typeof logString !== 'string') {\n // continue as planned\n return originalStdoutWrite(...args);\n }\n\n if (!logString.startsWith('LOG')) {\n if (logString.includes('Error:')) {\n this.log('error', logString);\n } else {\n this.log('info', logString);\n }\n return true;\n }\n\n return originalStdoutWrite(...args);\n };\n\n process.stderr.write = (...args: any) => {\n const logString: string = args[0];\n if (!logString || typeof logString !== 'string' || !logString.startsWith('LOG')) {\n this.log('error', logString);\n return true;\n }\n return originalStderrWrite(...args);\n };\n }\n this.consoleEnabled = true;\n }\n\n // =============\n // log functions\n // =============\n /**\n * main log method\n * @param logLevelArg - the log level\n * @param logMessageArg - the log message\n * @param logDataArg - any additional log data\n * @param correlationArg - info about corrleations\n */\n public async log(\n logLevelArg: plugins.smartlogInterfaces.TLogLevel,\n logMessageArg: string,\n logDataArg?: any,\n correlationArg?: plugins.smartlogInterfaces.ILogCorrelation\n ) {\n correlationArg = {\n ...{\n id: plugins.isounique.uni(),\n type: 'none',\n instance: this.uniInstanceId,\n },\n ...correlationArg,\n };\n\n if (this.consoleEnabled) {\n this.safeConsoleLog(`${logLevelArg}: ${logMessageArg}`);\n }\n\n const logPackage: plugins.smartlogInterfaces.ILogPackage = {\n timestamp: Date.now(),\n type: 'log',\n context: this.logContext,\n level: logLevelArg,\n correlation: correlationArg,\n message: logMessageArg,\n };\n if (logDataArg) {\n logPackage.data = logDataArg;\n }\n await this.logRouter.routeLog(logPackage);\n }\n\n public increment(\n logLevelArg: plugins.smartlogInterfaces.TLogLevel,\n logMessageArg: string,\n logDataArg?: any,\n correlationArg: plugins.smartlogInterfaces.ILogCorrelation = {\n id: plugins.isounique.uni(),\n type: 'none',\n }\n ) {\n if (this.consoleEnabled) {\n this.safeConsoleLog(`INCREMENT: ${logLevelArg}: ${logMessageArg}`);\n }\n this.logRouter.routeLog({\n timestamp: Date.now(),\n type: 'increment',\n context: this.logContext,\n level: logLevelArg,\n message: logMessageArg,\n correlation: correlationArg,\n });\n }\n\n public async handleLog(logPackageArg: plugins.smartlogInterfaces.ILogPackage) {\n await this.logRouter.routeLog(logPackageArg);\n }\n\n private safeConsoleLog(logLine: string) {\n console.log(\n `LOG => ${new Date().getHours()}:${new Date().getMinutes()}:${new Date().getSeconds()} => ${logLine}`\n );\n }\n\n public createLogGroup(transactionId: string = 'none') {\n return new LogGroup(this, transactionId);\n }\n}\n", "import * as plugins from './smartlog.plugins.js';\nimport { Smartlog } from './smartlog.classes.smartlog.js';\n\nexport class LogGroup {\n public smartlogRef: Smartlog;\n public transactionId: string;\n public groupId = plugins.isounique.uni();\n\n constructor(smartlogInstance: Smartlog, transactionIdArg: string) {\n this.smartlogRef = smartlogInstance;\n this.transactionId = transactionIdArg;\n }\n\n public log(\n logLevelArg: plugins.smartlogInterfaces.TLogLevel,\n logMessageArg: string,\n logDataArg?: any\n ) {\n this.smartlogRef.log(logLevelArg, logMessageArg, logDataArg, {\n id: plugins.isounique.uni(),\n type: 'none',\n group: this.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Aa,KAAK;AAAA,IACpB,CAAC;AAAA,EACH;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* autocreated commitinfo by @pushrocks/commitinfo
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
|
-
name: '@
|
|
6
|
-
version: '3.0.
|
|
7
|
-
description: 'minimalistic distributed and extensible logging tool'
|
|
5
|
+
name: '@push.rocks/smartlog',
|
|
6
|
+
version: '3.0.5',
|
|
7
|
+
description: 'A minimalistic, distributed, and extensible logging tool supporting centralized log management.'
|
|
8
8
|
};
|
|
9
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
9
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSxzQkFBc0I7SUFDNUIsT0FBTyxFQUFFLE9BQU87SUFDaEIsV0FBVyxFQUFFLGlHQUFpRztDQUMvRyxDQUFBIn0=
|
package/dist_ts/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import './smartlog.plugins.js';
|
|
1
|
+
import * as plugins from './smartlog.plugins.js';
|
|
2
2
|
import { ConsoleLog } from './smartlog.classes.consolelog.js';
|
|
3
3
|
import { LogGroup } from './smartlog.classes.loggroup.js';
|
|
4
4
|
import { Smartlog } from './smartlog.classes.smartlog.js';
|
|
5
5
|
export { ConsoleLog, LogGroup, Smartlog };
|
|
6
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
6
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssT0FBTyxNQUFNLHVCQUF1QixDQUFDO0FBQ2pELE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSxrQ0FBa0MsQ0FBQztBQUM5RCxPQUFPLEVBQUUsUUFBUSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDMUQsT0FBTyxFQUFFLFFBQVEsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBRTFELE9BQU8sRUFBRSxVQUFVLEVBQUUsUUFBUSxFQUFFLFFBQVEsRUFBRSxDQUFDIn0=
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import './smartlog.plugins.js';
|
|
1
|
+
import * as plugins from './smartlog.plugins.js';
|
|
2
2
|
/**
|
|
3
3
|
* a console log optimized for smartlog
|
|
4
4
|
*/
|
|
@@ -7,4 +7,4 @@ export class ConsoleLog {
|
|
|
7
7
|
console.log(`__# ${logLevelArg}: ${logMessageArg}`);
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
10
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRsb2cuY2xhc3Nlcy5jb25zb2xlbG9nLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRsb2cuY2xhc3Nlcy5jb25zb2xlbG9nLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxPQUFPLE1BQU0sdUJBQXVCLENBQUM7QUFFakQ7O0dBRUc7QUFDSCxNQUFNLE9BQU8sVUFBVTtJQUNkLEdBQUcsQ0FDUixXQUFpRCxFQUNqRCxhQUFxQixFQUNyQixPQUFhLEVBQ2IsY0FBMkQ7UUFFM0QsT0FBTyxDQUFDLEdBQUcsQ0FBQyxPQUFPLFdBQVcsS0FBSyxhQUFhLEVBQUUsQ0FBQyxDQUFDO0lBQ3RELENBQUM7Q0FDRiJ9
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as plugins from './smartlog.plugins.js';
|
|
2
|
-
import './smartlog.classes.smartlog.js';
|
|
2
|
+
import { Smartlog } from './smartlog.classes.smartlog.js';
|
|
3
3
|
export class LogGroup {
|
|
4
4
|
constructor(smartlogInstance, transactionIdArg) {
|
|
5
5
|
this.groupId = plugins.isounique.uni();
|
|
@@ -16,4 +16,4 @@ export class LogGroup {
|
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
19
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRsb2cuY2xhc3Nlcy5sb2dncm91cC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0bG9nLmNsYXNzZXMubG9nZ3JvdXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLE9BQU8sTUFBTSx1QkFBdUIsQ0FBQztBQUNqRCxPQUFPLEVBQUUsUUFBUSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFFMUQsTUFBTSxPQUFPLFFBQVE7SUFLbkIsWUFBWSxnQkFBMEIsRUFBRSxnQkFBd0I7UUFGekQsWUFBTyxHQUFHLE9BQU8sQ0FBQyxTQUFTLENBQUMsR0FBRyxFQUFFLENBQUM7UUFHdkMsSUFBSSxDQUFDLFdBQVcsR0FBRyxnQkFBZ0IsQ0FBQztRQUNwQyxJQUFJLENBQUMsYUFBYSxHQUFHLGdCQUFnQixDQUFDO0lBQ3hDLENBQUM7SUFFTSxHQUFHLENBQ1IsV0FBaUQsRUFDakQsYUFBcUIsRUFDckIsVUFBZ0I7UUFFaEIsSUFBSSxDQUFDLFdBQVcsQ0FBQyxHQUFHLENBQUMsV0FBVyxFQUFFLGFBQWEsRUFBRSxVQUFVLEVBQUU7WUFDM0QsRUFBRSxFQUFFLE9BQU8sQ0FBQyxTQUFTLENBQUMsR0FBRyxFQUFFO1lBQzNCLElBQUksRUFBRSxNQUFNO1lBQ1osS0FBSyxFQUFFLElBQUksQ0FBQyxPQUFPO1lBQ25CLFFBQVEsRUFBRSxJQUFJLENBQUMsV0FBVyxDQUFDLGFBQWE7WUFDeEMsV0FBVyxFQUFFLElBQUksQ0FBQyxhQUFhO1NBQ2hDLENBQUMsQ0FBQztJQUNMLENBQUM7Q0FDRiJ9
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as plugins from './smartlog.plugins.js';
|
|
2
2
|
export declare class LogRouter {
|
|
3
3
|
/**
|
|
4
4
|
* all log destinations
|
|
5
5
|
*/
|
|
6
6
|
private logDestinations;
|
|
7
7
|
constructor();
|
|
8
|
-
addLogDestination(logDestination: ILogDestination): void;
|
|
9
|
-
routeLog(logPackageArg: ILogPackage): Promise<void>;
|
|
8
|
+
addLogDestination(logDestination: plugins.smartlogInterfaces.ILogDestination): void;
|
|
9
|
+
routeLog(logPackageArg: plugins.smartlogInterfaces.ILogPackage): Promise<void>;
|
|
10
10
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import './smartlog.plugins.js';
|
|
2
|
-
import '@pushrocks/smartlog-interfaces';
|
|
1
|
+
import * as plugins from './smartlog.plugins.js';
|
|
3
2
|
export class LogRouter {
|
|
4
3
|
constructor() {
|
|
5
4
|
/**
|
|
@@ -17,4 +16,4 @@ export class LogRouter {
|
|
|
17
16
|
}
|
|
18
17
|
}
|
|
19
18
|
}
|
|
20
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
19
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRsb2cuY2xhc3Nlcy5sb2dyb3V0ZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGxvZy5jbGFzc2VzLmxvZ3JvdXRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssT0FBTyxNQUFNLHVCQUF1QixDQUFDO0FBRWpELE1BQU0sT0FBTyxTQUFTO0lBTXBCO1FBTEE7O1dBRUc7UUFDSyxvQkFBZSxHQUFpRCxFQUFFLENBQUM7SUFFNUQsQ0FBQztJQUVULGlCQUFpQixDQUFDLGNBQTBEO1FBQ2pGLElBQUksQ0FBQyxlQUFlLENBQUMsSUFBSSxDQUFDLGNBQWMsQ0FBQyxDQUFDO0lBQzVDLENBQUM7SUFFRCxvREFBb0Q7SUFDN0MsS0FBSyxDQUFDLFFBQVEsQ0FBQyxhQUFxRDtRQUN6RSxLQUFLLE1BQU0sY0FBYyxJQUFJLElBQUksQ0FBQyxlQUFlLEVBQUUsQ0FBQztZQUNsRCxNQUFNLGNBQWMsQ0FBQyxTQUFTLENBQUMsYUFBYSxDQUFDLENBQUM7UUFDaEQsQ0FBQztJQUNILENBQUM7Q0FDRiJ9
|
|
@@ -2,15 +2,15 @@ import * as plugins from './smartlog.plugins.js';
|
|
|
2
2
|
import { LogRouter } from './smartlog.classes.logrouter.js';
|
|
3
3
|
import { LogGroup } from './smartlog.classes.loggroup.js';
|
|
4
4
|
export class Smartlog {
|
|
5
|
+
addLogDestination(logDestinationArg) {
|
|
6
|
+
this.logRouter.addLogDestination(logDestinationArg);
|
|
7
|
+
}
|
|
5
8
|
constructor(optionsArg) {
|
|
6
9
|
this.uniInstanceId = plugins.isounique.uni();
|
|
7
10
|
this.logRouter = new LogRouter();
|
|
8
11
|
this.logContext = optionsArg.logContext;
|
|
9
12
|
this.minimumLogLevel = optionsArg.minimumLogLevel || 'silly';
|
|
10
13
|
}
|
|
11
|
-
addLogDestination(logDestinationArg) {
|
|
12
|
-
this.logRouter.addLogDestination(logDestinationArg);
|
|
13
|
-
}
|
|
14
14
|
// ============
|
|
15
15
|
// Logger Setup
|
|
16
16
|
// ============
|
|
@@ -20,34 +20,32 @@ export class Smartlog {
|
|
|
20
20
|
enableConsole(optionsArg) {
|
|
21
21
|
if (globalThis.process && optionsArg && optionsArg.captureAll) {
|
|
22
22
|
const process = globalThis.process;
|
|
23
|
-
const
|
|
23
|
+
const originalStdoutWrite = process.stdout.write.bind(process.stdout);
|
|
24
|
+
const originalStderrWrite = process.stderr.write.bind(process.stderr);
|
|
24
25
|
process.stdout.write = (...args) => {
|
|
25
26
|
const logString = args[0];
|
|
26
|
-
if (!logString || typeof logString
|
|
27
|
-
//
|
|
27
|
+
if (!logString || typeof logString !== 'string') {
|
|
28
|
+
// continue as planned
|
|
29
|
+
return originalStdoutWrite(...args);
|
|
28
30
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
this.log('info', logString);
|
|
31
|
+
if (!logString.startsWith('LOG')) {
|
|
32
|
+
if (logString.includes('Error:')) {
|
|
33
|
+
this.log('error', logString);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
this.log('info', logString);
|
|
36
37
|
}
|
|
37
38
|
return true;
|
|
38
39
|
}
|
|
39
|
-
|
|
40
|
-
write.apply(process.stdout, args);
|
|
41
|
-
return true;
|
|
40
|
+
return originalStdoutWrite(...args);
|
|
42
41
|
};
|
|
43
42
|
process.stderr.write = (...args) => {
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
const logString = args[0];
|
|
44
|
+
if (!logString || typeof logString !== 'string' || !logString.startsWith('LOG')) {
|
|
45
|
+
this.log('error', logString);
|
|
46
46
|
return true;
|
|
47
47
|
}
|
|
48
|
-
|
|
49
|
-
write.apply(process.stderr, args);
|
|
50
|
-
return true;
|
|
48
|
+
return originalStderrWrite(...args);
|
|
51
49
|
};
|
|
52
50
|
}
|
|
53
51
|
this.consoleEnabled = true;
|
|
@@ -113,4 +111,4 @@ export class Smartlog {
|
|
|
113
111
|
return new LogGroup(this, transactionId);
|
|
114
112
|
}
|
|
115
113
|
}
|
|
116
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
114
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRsb2cuY2xhc3Nlcy5zbWFydGxvZy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0bG9nLmNsYXNzZXMuc21hcnRsb2cudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLE9BQU8sTUFBTSx1QkFBdUIsQ0FBQztBQUVqRCxPQUFPLEVBQUUsU0FBUyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDNUQsT0FBTyxFQUFFLFFBQVEsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBTzFELE1BQU0sT0FBTyxRQUFRO0lBVVosaUJBQWlCLENBQUMsaUJBQTZEO1FBQ3BGLElBQUksQ0FBQyxTQUFTLENBQUMsaUJBQWlCLENBQUMsaUJBQWlCLENBQUMsQ0FBQztJQUN0RCxDQUFDO0lBRUQsWUFBWSxVQUFzQztRQVYzQyxrQkFBYSxHQUFXLE9BQU8sQ0FBQyxTQUFTLENBQUMsR0FBRyxFQUFFLENBQUM7UUFJL0MsY0FBUyxHQUFHLElBQUksU0FBUyxFQUFFLENBQUM7UUFPbEMsSUFBSSxDQUFDLFVBQVUsR0FBRyxVQUFVLENBQUMsVUFBVSxDQUFDO1FBQ3hDLElBQUksQ0FBQyxlQUFlLEdBQUcsVUFBVSxDQUFDLGVBQWUsSUFBSSxPQUFPLENBQUM7SUFDL0QsQ0FBQztJQUVELGVBQWU7SUFDZixlQUFlO0lBQ2YsZUFBZTtJQUVmOztPQUVHO0lBQ0ksYUFBYSxDQUFDLFVBQW9DO1FBQ3ZELElBQUksVUFBVSxDQUFDLE9BQU8sSU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QUN0QixXQUFXLEVBQUUsY0FBYztTQUM1QixDQUFDLENBQUM7SUFDTCxDQUFDO0lBRU0sS0FBSyxDQUFDLFNBQVMsQ0FBQyxhQUFxRDtRQUMxRSxNQUFNLElBQUksQ0FBQyxTQUFTLENBQUMsUUFBUSxDQUFDLGFBQWEsQ0FBQyxDQUFDO0lBQy9DLENBQUM7SUFFTyxjQUFjLENBQUMsT0FBZTtRQUNwQyxPQUFPLENBQUMsR0FBRyxDQUNULFVBQVUsSUFBSSxJQUFJLEVBQUUsQ0FBQyxRQUFRLEVBQUUsSUFBSSxJQUFJLElBQUksRUFBRSxDQUFDLFVBQVUsRUFBRSxJQUFJLElBQUksSUFBSSxFQUFFLENBQUMsVUFBVSxFQUFFLE9BQU8sT0FBTyxFQUFFLENBQ3RHLENBQUM7SUFDSixDQUFDO0lBRU0sY0FBYyxDQUFDLGdCQUF3QixNQUFNO1FBQ2xELE9BQU8sSUFBSSxRQUFRLENBQUMsSUFBSSxFQUFFLGFBQWEsQ0FBQyxDQUFDO0lBQzNDLENBQUM7Q0FDRiJ9
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import * as isounique from '@
|
|
2
|
-
import * as smartlogInterfaces from '@
|
|
1
|
+
import * as isounique from '@push.rocks/isounique';
|
|
2
|
+
import * as smartlogInterfaces from '@push.rocks/smartlog-interfaces';
|
|
3
3
|
export { isounique, smartlogInterfaces };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as isounique from '@
|
|
2
|
-
import * as smartlogInterfaces from '@
|
|
1
|
+
import * as isounique from '@push.rocks/isounique';
|
|
2
|
+
import * as smartlogInterfaces from '@push.rocks/smartlog-interfaces';
|
|
3
3
|
export { isounique, smartlogInterfaces };
|
|
4
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRsb2cucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0bG9nLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLFNBQVMsTUFBTSx1QkFBdUIsQ0FBQztBQUNuRCxPQUFPLEtBQUssa0JBQWtCLE1BQU0saUNBQWlDLENBQUM7QUFFdEUsT0FBTyxFQUFFLFNBQVMsRUFBRSxrQkFBa0IsRUFBRSxDQUFDIn0=
|
package/npmextra.json
CHANGED
|
@@ -2,17 +2,36 @@
|
|
|
2
2
|
"gitzone": {
|
|
3
3
|
"projectType": "npm",
|
|
4
4
|
"module": {
|
|
5
|
-
"githost": "
|
|
6
|
-
"gitscope": "
|
|
5
|
+
"githost": "code.foss.global",
|
|
6
|
+
"gitscope": "push.rocks",
|
|
7
7
|
"gitrepo": "smartlog",
|
|
8
|
-
"description": "minimalistic distributed and extensible logging tool",
|
|
9
|
-
"npmPackagename": "@
|
|
8
|
+
"description": "A minimalistic, distributed, and extensible logging tool supporting centralized log management.",
|
|
9
|
+
"npmPackagename": "@push.rocks/smartlog",
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"projectDomain": "push.rocks"
|
|
11
|
+
"projectDomain": "push.rocks",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"logging",
|
|
14
|
+
"log management",
|
|
15
|
+
"typescript",
|
|
16
|
+
"centralized logging",
|
|
17
|
+
"json logging",
|
|
18
|
+
"node.js",
|
|
19
|
+
"distributed systems",
|
|
20
|
+
"extensible logging",
|
|
21
|
+
"log routing",
|
|
22
|
+
"console logging",
|
|
23
|
+
"log destinations",
|
|
24
|
+
"log levels",
|
|
25
|
+
"error tracking",
|
|
26
|
+
"development tools"
|
|
27
|
+
]
|
|
12
28
|
}
|
|
13
29
|
},
|
|
14
30
|
"npmci": {
|
|
15
31
|
"npmGlobalTools": [],
|
|
16
32
|
"npmAccessLevel": "public"
|
|
33
|
+
},
|
|
34
|
+
"tsdoc": {
|
|
35
|
+
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
|
17
36
|
}
|
|
18
37
|
}
|
package/package.json
CHANGED
|
@@ -1,37 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@push.rocks/smartlog",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.5",
|
|
4
4
|
"private": false,
|
|
5
|
-
"description": "minimalistic distributed and extensible logging tool",
|
|
5
|
+
"description": "A minimalistic, distributed, and extensible logging tool supporting centralized log management.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"logging",
|
|
8
|
+
"log management",
|
|
9
|
+
"typescript",
|
|
8
10
|
"centralized logging",
|
|
9
11
|
"json logging",
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
12
|
+
"node.js",
|
|
13
|
+
"distributed systems",
|
|
14
|
+
"extensible logging",
|
|
15
|
+
"log routing",
|
|
16
|
+
"console logging",
|
|
17
|
+
"log destinations",
|
|
18
|
+
"log levels",
|
|
19
|
+
"error tracking",
|
|
20
|
+
"development tools"
|
|
13
21
|
],
|
|
14
22
|
"main": "dist_ts/index.js",
|
|
15
23
|
"typings": "dist_ts/index.d.ts",
|
|
16
24
|
"author": "Lossless GmbH",
|
|
17
25
|
"license": "MIT",
|
|
18
|
-
"scripts": {
|
|
19
|
-
"test": "(tstest test/)",
|
|
20
|
-
"build": "(tsbuild --web && tsbundle npm)",
|
|
21
|
-
"format": "(gitzone format)",
|
|
22
|
-
"buildDocs": "tsdoc"
|
|
23
|
-
},
|
|
24
26
|
"devDependencies": {
|
|
25
|
-
"@
|
|
26
|
-
"@
|
|
27
|
-
"@
|
|
28
|
-
"@
|
|
29
|
-
"@
|
|
30
|
-
"@types/node": "^
|
|
27
|
+
"@git.zone/tsbuild": "^2.1.66",
|
|
28
|
+
"@git.zone/tsbundle": "^2.0.8",
|
|
29
|
+
"@git.zone/tsrun": "^1.2.44",
|
|
30
|
+
"@git.zone/tstest": "^1.0.77",
|
|
31
|
+
"@push.rocks/tapbundle": "^5.0.23",
|
|
32
|
+
"@types/node": "^20.12.12"
|
|
31
33
|
},
|
|
32
34
|
"dependencies": {
|
|
33
|
-
"@
|
|
34
|
-
"@
|
|
35
|
+
"@push.rocks/isounique": "^1.0.4",
|
|
36
|
+
"@push.rocks/smartlog-interfaces": "^3.0.0"
|
|
35
37
|
},
|
|
36
38
|
"files": [
|
|
37
39
|
"ts/**/*",
|
|
@@ -48,5 +50,11 @@
|
|
|
48
50
|
"browserslist": [
|
|
49
51
|
"last 1 chrome versions"
|
|
50
52
|
],
|
|
51
|
-
"type": "module"
|
|
53
|
+
"type": "module",
|
|
54
|
+
"scripts": {
|
|
55
|
+
"test": "(tstest test/)",
|
|
56
|
+
"build": "(tsbuild --web && tsbundle npm)",
|
|
57
|
+
"format": "(gitzone format)",
|
|
58
|
+
"buildDocs": "tsdoc"
|
|
59
|
+
}
|
|
52
60
|
}
|
package/readme.hints.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/readme.md
CHANGED
|
@@ -1,38 +1,30 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @push.rocks/smartlog
|
|
2
|
+
|
|
2
3
|
minimalistic distributed and extensible logging tool
|
|
3
4
|
|
|
4
|
-
##
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
-- | --
|
|
14
|
-
GitLab Pipelines | [](https://lossless.cloud)
|
|
15
|
-
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
|
16
|
-
npm | [](https://lossless.cloud)
|
|
17
|
-
Snyk | [](https://lossless.cloud)
|
|
18
|
-
TypeScript Support | [](https://lossless.cloud)
|
|
19
|
-
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
|
20
|
-
Code Style | [](https://lossless.cloud)
|
|
21
|
-
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
|
22
|
-
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
|
23
|
-
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
|
24
|
-
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
You can install `@push.rocks/smartlog` using npm:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @push.rocks/smartlog --save
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Ensure that you have TypeScript and node.js installed in your development environment, as this module is intended to be used with TypeScript.
|
|
25
14
|
|
|
26
15
|
## Usage
|
|
27
16
|
|
|
28
|
-
|
|
17
|
+
`@push.rocks/smartlog` is a flexible and extensible logging tool designed to provide a minimalistic yet powerful logging solution across different environments, making it especially useful in distributed systems. This documentation aims to guide you through its capabilities, setup, and how to integrate it seamlessly into your TypeScript projects.
|
|
18
|
+
|
|
19
|
+
### Creating a Logger Instance
|
|
29
20
|
|
|
30
|
-
|
|
21
|
+
Start by importing `Smartlog` and create a logger instance by providing a context that describes your logging environment:
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { Smartlog } from '@push.rocks/smartlog';
|
|
31
25
|
|
|
32
|
-
```ts
|
|
33
|
-
import { Smartlog } from '@pushrocks/smartlog';
|
|
34
26
|
const logger = new Smartlog({
|
|
35
|
-
{
|
|
27
|
+
logContext: {
|
|
36
28
|
company: 'My awesome company',
|
|
37
29
|
companyunit: 'my awesome cloud team',
|
|
38
30
|
containerName: 'awesome-container',
|
|
@@ -40,49 +32,89 @@ const logger = new Smartlog({
|
|
|
40
32
|
runtime: 'node',
|
|
41
33
|
zone: 'zone x'
|
|
42
34
|
}
|
|
43
|
-
})
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
This context enriches your logs with valuable information, making them easier to filter and analyze in a distributed system.
|
|
39
|
+
|
|
40
|
+
### Logging Messages
|
|
41
|
+
|
|
42
|
+
Logging is straightforward; you can log messages at various levels such as `info`, `warn`, `error`, `silly`, etc.:
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
logger.log('info', 'This is an info message');
|
|
46
|
+
logger.log('error', 'This is an error message with details', { errorCode: 123 });
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The logging method accepts additional data as the third parameter, allowing you to attach more context to each log message, which is immensely useful for debugging.
|
|
50
|
+
|
|
51
|
+
### Using the Default Logger
|
|
44
52
|
|
|
45
|
-
|
|
53
|
+
For convenience, `@push.rocks/smartlog` provides a default logger that you can use out of the box:
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
import { defaultLogger } from '@push.rocks/smartlog';
|
|
57
|
+
|
|
58
|
+
defaultLogger.log('warn', 'This is a warning message using the default logger');
|
|
46
59
|
```
|
|
47
60
|
|
|
48
|
-
|
|
61
|
+
This is particularly helpful for simple applications or for initial project setup.
|
|
62
|
+
|
|
63
|
+
### Extending With Log Destinations
|
|
64
|
+
|
|
65
|
+
One of the core strengths of `@push.rocks/smartlog` is its ability to work with multiple log destinations, enabling you to log messages not just to the console but also to external logging services or custom destinations.
|
|
49
66
|
|
|
50
|
-
|
|
51
|
-
import { Smartlog, defaultLogger } from '@pushrocks/smartlog';
|
|
67
|
+
To add a log destination, you create a class that implements the `ILogDestination` interface and then add it to the logger:
|
|
52
68
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
69
|
+
```typescript
|
|
70
|
+
import { Smartlog, ILogDestination } from '@push.rocks/smartlog';
|
|
71
|
+
|
|
72
|
+
class MyCustomLogDestination implements ILogDestination {
|
|
73
|
+
async handleLog(logPackage) {
|
|
74
|
+
// Implement your custom logging logic here
|
|
75
|
+
console.log(`Custom log: ${logPackage.message}`);
|
|
57
76
|
}
|
|
58
77
|
}
|
|
78
|
+
|
|
79
|
+
const logger = new Smartlog({ logContext: { /* your context */ } });
|
|
80
|
+
logger.addLogDestination(new MyCustomLogDestination());
|
|
59
81
|
```
|
|
60
82
|
|
|
61
|
-
|
|
83
|
+
After adding your custom log destination(s), every log message sent through `Smartlog` will also be routed to them according to their implementation.
|
|
62
84
|
|
|
63
|
-
|
|
85
|
+
### Integration with Logging Services
|
|
64
86
|
|
|
65
|
-
|
|
87
|
+
`@push.rocks/smartlog` is designed to be extensible; you can integrate it with various logging services like Scalyr, Elasticsearch, LogDNA, etc., by developing or using existing log destinations conforming to those services.
|
|
66
88
|
|
|
67
|
-
|
|
68
|
-
- [@pushrocks/smartlog-destination-devtools](https://www.npmjs.com/package/@pushrocks/smartlog-destination-devtools) - outputs logs into the browser console in a colorful, nice to read way.
|
|
69
|
-
- [@pushrocks/smartlog-destination-receiver](https://www.npmjs.com/package/@pushrocks/smartlog-destination-receiver) - sends logs to a smartlog receiver (more about that below)
|
|
70
|
-
- [@mojoio/scalyr](https://www.npmjs.com/package/@pushrocks/smartlog-destination-receiver) - an scalyr API package that comes with a smartlog log destination included
|
|
71
|
-
- [@mojoio/elasticsearch](https://www.npmjs.com/package/@mojoio/elasticsearch) - an elasticsearch API package that comes with a smartlog destination included
|
|
89
|
+
Check the npm registry or GitHub for community-contributed log destinations that can seamlessly integrate `@push.rocks/smartlog` into your preferred logging infrastructure.
|
|
72
90
|
|
|
73
|
-
###
|
|
91
|
+
### Advanced Usage
|
|
74
92
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
93
|
+
- **Log Groups**: You can use log groups to associate related log messages, which is especially handy for tracking logs across distributed systems.
|
|
94
|
+
- **Custom Log Levels**: Beyond the standard log levels, you can define custom log levels that suit your project needs.
|
|
95
|
+
- **Dynamic Log Contexts**: The log context can be dynamically adjusted to reflect different stages or aspects of your application logic.
|
|
96
|
+
|
|
97
|
+
### Conclusion
|
|
98
|
+
|
|
99
|
+
`@push.rocks/smartlog` empowers you to implement a robust logging solution tailored to your needs with minimal effort. Its design promotes clarity, flexibility, and integration ease, making it an excellent choice for projects of any scale.
|
|
100
|
+
|
|
101
|
+
Remember to refer to the official documentation and the type definitions for detailed information on all available methods and configurations. Happy logging!
|
|
102
|
+
|
|
103
|
+
## License and Legal Information
|
|
104
|
+
|
|
105
|
+
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
|
|
106
|
+
|
|
107
|
+
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
|
108
|
+
|
|
109
|
+
### Trademarks
|
|
78
110
|
|
|
79
|
-
|
|
111
|
+
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
|
|
80
112
|
|
|
81
|
-
|
|
113
|
+
### Company Information
|
|
82
114
|
|
|
83
|
-
|
|
115
|
+
Task Venture Capital GmbH
|
|
116
|
+
Registered at District court Bremen HRB 35230 HB, Germany
|
|
84
117
|
|
|
85
|
-
|
|
86
|
-
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
|
118
|
+
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
|
87
119
|
|
|
88
|
-
|
|
120
|
+
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
package/ts/00_commitinfo_data.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* autocreated commitinfo by @pushrocks/commitinfo
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
|
-
name: '@
|
|
6
|
-
version: '3.0.
|
|
7
|
-
description: 'minimalistic distributed and extensible logging tool'
|
|
5
|
+
name: '@push.rocks/smartlog',
|
|
6
|
+
version: '3.0.5',
|
|
7
|
+
description: 'A minimalistic, distributed, and extensible logging tool supporting centralized log management.'
|
|
8
8
|
}
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import * as plugins from './smartlog.plugins.js';
|
|
2
2
|
|
|
3
|
-
import { ILogDestination, ILogPackage } from '@pushrocks/smartlog-interfaces';
|
|
4
|
-
|
|
5
3
|
export class LogRouter {
|
|
6
4
|
/**
|
|
7
5
|
* all log destinations
|
|
8
6
|
*/
|
|
9
|
-
private logDestinations: ILogDestination[] = [];
|
|
7
|
+
private logDestinations: plugins.smartlogInterfaces.ILogDestination[] = [];
|
|
10
8
|
|
|
11
9
|
constructor() {}
|
|
12
10
|
|
|
13
|
-
public addLogDestination(logDestination: ILogDestination) {
|
|
11
|
+
public addLogDestination(logDestination: plugins.smartlogInterfaces.ILogDestination) {
|
|
14
12
|
this.logDestinations.push(logDestination);
|
|
15
13
|
}
|
|
16
14
|
|
|
17
15
|
// routes the log according to added logDestinations
|
|
18
|
-
public async routeLog(logPackageArg: ILogPackage) {
|
|
16
|
+
public async routeLog(logPackageArg: plugins.smartlogInterfaces.ILogPackage) {
|
|
19
17
|
for (const logDestination of this.logDestinations) {
|
|
20
18
|
await logDestination.handleLog(logPackageArg);
|
|
21
19
|
}
|
|
@@ -37,34 +37,35 @@ export class Smartlog implements plugins.smartlogInterfaces.ILogDestination {
|
|
|
37
37
|
public enableConsole(optionsArg?: { captureAll: boolean }) {
|
|
38
38
|
if (globalThis.process && optionsArg && optionsArg.captureAll) {
|
|
39
39
|
const process = globalThis.process;
|
|
40
|
-
const
|
|
40
|
+
const originalStdoutWrite = process.stdout.write.bind(process.stdout);
|
|
41
|
+
const originalStderrWrite = process.stderr.write.bind(process.stderr);
|
|
42
|
+
|
|
41
43
|
process.stdout.write = (...args: any) => {
|
|
42
44
|
const logString: string = args[0];
|
|
43
|
-
if (!logString || typeof logString
|
|
44
|
-
//
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
if (!logString || typeof logString !== 'string') {
|
|
46
|
+
// continue as planned
|
|
47
|
+
return originalStdoutWrite(...args);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (!logString.startsWith('LOG')) {
|
|
51
|
+
if (logString.includes('Error:')) {
|
|
52
|
+
this.log('error', logString);
|
|
53
|
+
} else {
|
|
54
|
+
this.log('info', logString);
|
|
52
55
|
}
|
|
53
56
|
return true;
|
|
54
57
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return true;
|
|
58
|
+
|
|
59
|
+
return originalStdoutWrite(...args);
|
|
58
60
|
};
|
|
59
61
|
|
|
60
62
|
process.stderr.write = (...args: any) => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
const logString: string = args[0];
|
|
64
|
+
if (!logString || typeof logString !== 'string' || !logString.startsWith('LOG')) {
|
|
65
|
+
this.log('error', logString);
|
|
63
66
|
return true;
|
|
64
67
|
}
|
|
65
|
-
|
|
66
|
-
write.apply(process.stderr, args);
|
|
67
|
-
return true;
|
|
68
|
+
return originalStderrWrite(...args);
|
|
68
69
|
};
|
|
69
70
|
}
|
|
70
71
|
this.consoleEnabled = true;
|
package/ts/smartlog.plugins.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as isounique from '@
|
|
2
|
-
import * as smartlogInterfaces from '@
|
|
1
|
+
import * as isounique from '@push.rocks/isounique';
|
|
2
|
+
import * as smartlogInterfaces from '@push.rocks/smartlog-interfaces';
|
|
3
3
|
|
|
4
4
|
export { isounique, smartlogInterfaces };
|