Node.js console.log() in txt file

后端 未结 6 526
耶瑟儿~
耶瑟儿~ 2020-12-24 03:29

I have another question (last question). At the moment i am working on a Node.js project and in this I have many console.log() functions. This has worked ok

6条回答
  •  北荒
    北荒 (楼主)
    2020-12-24 04:01

    Just write your own log function:

    function log(message) {
       console.log(message);
       fs.writeFileSync(...);
    }
    

    Then replace all your existing calls to console.log() with log().

提交回复
热议问题