Created
April 25, 2024 04:38
-
-
Save dbwodlf3/cc2da275db08c0a9f2f6b7d5e40840c8 to your computer and use it in GitHub Desktop.
node debugging with file log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fs from "fs"; | |
import util from "util"; | |
const logFile = fs.createWriteStream('output.log', { flags: 'a' }); | |
console.log = function (msg) { | |
logFile.write(util.format(msg) + '\n'); // 메시지를 파일에 쓰기 | |
process.stdout.write(util.format(msg) + '\n'); // 표준 출력에도 쓰기 | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment