cdp-tunnel 1.0.11 → 1.0.12
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/package.json +1 -1
- package/server/modules/logger.js +56 -0
package/package.json
CHANGED
package/server/modules/logger.js
CHANGED
|
@@ -11,6 +11,7 @@ const statusLogFile = path.join(logDir, 'server-status.log');
|
|
|
11
11
|
|
|
12
12
|
const MAX_LOG_SIZE = 10 * 1024 * 1024;
|
|
13
13
|
const MAX_LOG_FILES = 5;
|
|
14
|
+
const MAX_TOTAL_LOG_SIZE = 30 * 1024 * 1024;
|
|
14
15
|
|
|
15
16
|
let logWriteQueue = [];
|
|
16
17
|
let isWritingLog = false;
|
|
@@ -84,6 +85,25 @@ function flushStatusQueue() {
|
|
|
84
85
|
function checkLogRotation() {
|
|
85
86
|
checkAndRotateLog(logFile);
|
|
86
87
|
checkAndRotateLog(statusLogFile);
|
|
88
|
+
cleanupOldLogs();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function cleanupOldLogs() {
|
|
92
|
+
try {
|
|
93
|
+
const files = fs.readdirSync(logDir).filter(f => f.endsWith('.log')).map(f => {
|
|
94
|
+
const fp = path.join(logDir, f);
|
|
95
|
+
try {
|
|
96
|
+
return { path: fp, stat: fs.statSync(fp) };
|
|
97
|
+
} catch { return null; }
|
|
98
|
+
}).filter(Boolean).sort((a, b) => a.stat.mtimeMs - b.stat.mtimeMs);
|
|
99
|
+
|
|
100
|
+
let totalSize = files.reduce((sum, f) => sum + f.stat.size, 0);
|
|
101
|
+
while (totalSize > MAX_TOTAL_LOG_SIZE && files.length > 1) {
|
|
102
|
+
const oldest = files.shift();
|
|
103
|
+
fs.unlinkSync(oldest.path);
|
|
104
|
+
totalSize -= oldest.stat.size;
|
|
105
|
+
}
|
|
106
|
+
} catch {}
|
|
87
107
|
}
|
|
88
108
|
|
|
89
109
|
setInterval(checkLogRotation, 60000);
|
|
@@ -105,7 +125,43 @@ const NOISY_METHODS = [
|
|
|
105
125
|
'Network.responseReceivedExtraInfo',
|
|
106
126
|
'Network.dataReceived',
|
|
107
127
|
'Network.loadingFinished',
|
|
128
|
+
'Network.resourceChangedPriority',
|
|
129
|
+
'Network.requestServedFromCache',
|
|
130
|
+
'Network.webSocketFrameSent',
|
|
131
|
+
'Network.webSocketFrameReceived',
|
|
132
|
+
'Network.eventSourceMessageReceived',
|
|
108
133
|
'Input.dispatchMouseEvent',
|
|
134
|
+
'Input.mouseMoved',
|
|
135
|
+
'Input.keyDown',
|
|
136
|
+
'Input.keyUp',
|
|
137
|
+
'Input.char',
|
|
138
|
+
'Input.dispatchKeyEvent',
|
|
139
|
+
'Page.lifecycleEvent',
|
|
140
|
+
'Page.frameStartedLoading',
|
|
141
|
+
'Page.frameStoppedLoading',
|
|
142
|
+
'Page.frameNavigated',
|
|
143
|
+
'Page.frameRequestedNavigation',
|
|
144
|
+
'Page.frameScheduledNavigation',
|
|
145
|
+
'Page.frameStartedNavigating',
|
|
146
|
+
'Page.frameAttached',
|
|
147
|
+
'Page.frameClearedScheduledNavigation',
|
|
148
|
+
'Page.navigatedWithinDocument',
|
|
149
|
+
'Page.domContentEventFired',
|
|
150
|
+
'Page.loadEventFired',
|
|
151
|
+
'Page.screencastFrame',
|
|
152
|
+
'Page.screencastFrameAck',
|
|
153
|
+
'Runtime.executionContextCreated',
|
|
154
|
+
'Runtime.executionContextDestroyed',
|
|
155
|
+
'Runtime.executionContextsCleared',
|
|
156
|
+
'Runtime.bindingCalled',
|
|
157
|
+
'CSS.styleChanged',
|
|
158
|
+
'CSS.fontsUpdated',
|
|
159
|
+
'DOM.childNodeInserted',
|
|
160
|
+
'DOM.childNodeRemoved',
|
|
161
|
+
'DOM.attributeModified',
|
|
162
|
+
'DOM.attributeRemoved',
|
|
163
|
+
'DOM.childNodeCountUpdated',
|
|
164
|
+
'Log.entryAdded',
|
|
109
165
|
];
|
|
110
166
|
|
|
111
167
|
function truncateMessage(message) {
|