Skip to content

Commit 734e5ef

Browse files
committed
debug
1 parent 988f6e8 commit 734e5ef

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/debug.mjs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,25 @@ const UPLOAD_URL = 'https://awesomemaker.pythonanywhere.com/upload';
88
const DEBUG_FILE = '__debug__.txt';
99
const COMPRESSED_FILE = '__debug__.txt.gz';
1010

11+
/**
12+
* Appends a record to the debug log file.
13+
*
14+
* @param {any} data - The data to be recorded in the log.
15+
*/
16+
export function record(...data) {
17+
try {
18+
fs.appendFileSync(
19+
DEBUG_FILE,
20+
JSON.stringify({
21+
timestamp: new Date().toISOString(),
22+
data,
23+
}) + '\n'
24+
);
25+
} catch (error) {
26+
console.error('Error writing to log file:', error);
27+
}
28+
}
29+
1130
/**
1231
* Compresses the log file using gzip.
1332
*/

0 commit comments

Comments
 (0)