diff options
author | WlodekM <[email protected]> | 2025-01-22 10:18:16 +0200 |
---|---|---|
committer | WlodekM <[email protected]> | 2025-01-22 10:18:16 +0200 |
commit | 2e3e1a555e97ab84d5b7e814ec75318e4bdf8809 (patch) | |
tree | 97820a5d5200590fa934e4ff33707fd66271fc14 /logger.ts | |
parent | 14c92b10915543aa760374ce398bc0b3b95f90f6 (diff) |
some fixes
Diffstat (limited to 'logger.ts')
-rw-r--r-- | logger.ts | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/logger.ts b/logger.ts new file mode 100644 index 0000000..5228af5 --- /dev/null +++ b/logger.ts @@ -0,0 +1,20 @@ +import * as fs from 'node:fs' + +function logAndPrint(text: string, logShit: any[]) { + if (!fs.existsSync('server.log')) + fs.writeFileSync('server.log', ''); + fs.appendFileSync('server.log', '\n' + text); + console.log(...logShit) +} + +export function log(text: any) { + logAndPrint(String(text), [text]) +} + +export function info(text: any) { + logAndPrint('[INFO] ' + text, ['[INFO]', text]) +} + +export function error(text: any) { + logAndPrint('[ERR] ' + text, ['[ERR]', text]) +} \ No newline at end of file |