@ngn-net/nestjs-telescope 0.2.10 → 0.2.11
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/ui/manifest.json +2 -2
- package/dist/watchers/log.watcher.js +50 -68
- package/package.json +1 -1
package/dist/ui/manifest.json
CHANGED
|
@@ -14,44 +14,6 @@ exports.LogWatcher = void 0;
|
|
|
14
14
|
const common_1 = require("@nestjs/common");
|
|
15
15
|
const telescope_service_1 = require("../telescope.service");
|
|
16
16
|
const entry_type_enum_1 = require("../enums/entry-type.enum");
|
|
17
|
-
class TelescopeLoggerWrapper {
|
|
18
|
-
original;
|
|
19
|
-
recordLog;
|
|
20
|
-
constructor(original, recordLog) {
|
|
21
|
-
this.original = original;
|
|
22
|
-
this.recordLog = recordLog;
|
|
23
|
-
}
|
|
24
|
-
log(message, ...optionalParams) {
|
|
25
|
-
this.recordLog('log', message, ...optionalParams);
|
|
26
|
-
this.original.log(message, ...optionalParams);
|
|
27
|
-
}
|
|
28
|
-
error(message, ...optionalParams) {
|
|
29
|
-
this.recordLog('error', message, ...optionalParams);
|
|
30
|
-
this.original.error(message, ...optionalParams);
|
|
31
|
-
}
|
|
32
|
-
warn(message, ...optionalParams) {
|
|
33
|
-
this.recordLog('warn', message, ...optionalParams);
|
|
34
|
-
this.original.warn(message, ...optionalParams);
|
|
35
|
-
}
|
|
36
|
-
debug(message, ...optionalParams) {
|
|
37
|
-
this.recordLog('debug', message, ...optionalParams);
|
|
38
|
-
if (this.original.debug) {
|
|
39
|
-
this.original.debug(message, ...optionalParams);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
verbose(message, ...optionalParams) {
|
|
43
|
-
this.recordLog('verbose', message, ...optionalParams);
|
|
44
|
-
if (this.original.verbose) {
|
|
45
|
-
this.original.verbose(message, ...optionalParams);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
fatal(message, ...optionalParams) {
|
|
49
|
-
this.recordLog('fatal', message, ...optionalParams);
|
|
50
|
-
if (this.original.fatal) {
|
|
51
|
-
this.original.fatal(message, ...optionalParams);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
17
|
let LogWatcher = class LogWatcher {
|
|
56
18
|
telescope;
|
|
57
19
|
isRecording = false; // Guard against infinite recursion
|
|
@@ -101,39 +63,59 @@ let LogWatcher = class LogWatcher {
|
|
|
101
63
|
recordConsoleLog('debug', args);
|
|
102
64
|
return originalDebug(...args);
|
|
103
65
|
};
|
|
104
|
-
// 2. Intercept NestJS Logger
|
|
66
|
+
// 2. Intercept NestJS static Logger methods directly
|
|
105
67
|
try {
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
68
|
+
const originalStaticLog = common_1.Logger.log;
|
|
69
|
+
const originalStaticError = common_1.Logger.error;
|
|
70
|
+
const originalStaticWarn = common_1.Logger.warn;
|
|
71
|
+
const originalStaticDebug = common_1.Logger.debug;
|
|
72
|
+
const originalStaticVerbose = common_1.Logger.verbose;
|
|
73
|
+
const recordNestLog = (level, message, optionalParams) => {
|
|
74
|
+
if (self.isRecording)
|
|
75
|
+
return;
|
|
76
|
+
let formattedMessage = typeof message === 'object' ? JSON.stringify(message) : String(message);
|
|
77
|
+
if (optionalParams.length > 0) {
|
|
78
|
+
const context = optionalParams[0];
|
|
79
|
+
const contextStr = typeof context === 'string' ? `[${context}] ` : '';
|
|
80
|
+
formattedMessage = contextStr + formattedMessage;
|
|
81
|
+
}
|
|
82
|
+
if (formattedMessage.includes('telescope_entries') || formattedMessage.includes('TelescopeModule')) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
self.isRecording = true;
|
|
86
|
+
try {
|
|
87
|
+
self.telescope.record({
|
|
88
|
+
type: entry_type_enum_1.EntryType.LOG,
|
|
89
|
+
content: { level, message: formattedMessage },
|
|
90
|
+
}).catch(() => { });
|
|
91
|
+
}
|
|
92
|
+
finally {
|
|
93
|
+
self.isRecording = false;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
common_1.Logger.log = function (message, ...optionalParams) {
|
|
97
|
+
recordNestLog('log', message, optionalParams);
|
|
98
|
+
return originalStaticLog.call(common_1.Logger, message, ...optionalParams);
|
|
99
|
+
};
|
|
100
|
+
common_1.Logger.error = function (message, ...optionalParams) {
|
|
101
|
+
recordNestLog('error', message, optionalParams);
|
|
102
|
+
return originalStaticError.call(common_1.Logger, message, ...optionalParams);
|
|
103
|
+
};
|
|
104
|
+
common_1.Logger.warn = function (message, ...optionalParams) {
|
|
105
|
+
recordNestLog('warn', message, optionalParams);
|
|
106
|
+
return originalStaticWarn.call(common_1.Logger, message, ...optionalParams);
|
|
107
|
+
};
|
|
108
|
+
common_1.Logger.debug = function (message, ...optionalParams) {
|
|
109
|
+
recordNestLog('debug', message, optionalParams);
|
|
110
|
+
return originalStaticDebug.call(common_1.Logger, message, ...optionalParams);
|
|
111
|
+
};
|
|
112
|
+
common_1.Logger.verbose = function (message, ...optionalParams) {
|
|
113
|
+
recordNestLog('verbose', message, optionalParams);
|
|
114
|
+
return originalStaticVerbose.call(common_1.Logger, message, ...optionalParams);
|
|
115
|
+
};
|
|
134
116
|
}
|
|
135
117
|
catch {
|
|
136
|
-
// Ignore errors
|
|
118
|
+
// Ignore patching errors to protect app stability
|
|
137
119
|
}
|
|
138
120
|
}
|
|
139
121
|
};
|