简体   繁体   中英

Enabling console.log in production mode in node.js

I have over-ridden my console.log to create a log file of everything passed to it. This works great when in dev mode but the log files are empty when in production mode, presumably because console.log doesn't get called?

Anyone know how to enable it so it gets called in production mode?

Thanks

I guess you are trying to print data to the console overview of the Node without using the console function.

process.stdout.write("text" + somevar);

maybe?

Edit:

The function you are asking consists of printing to the console with timestamp. (Aircoded, might fail, but you'll get the concept)

function TSprint(input){
    process.stdout.write(Date.getTime() + " |> " + input + "\n");
}

Probably print something like January 1, 1970, 00:00:00 |> My input.

PS: stdout does not create a new line.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM