1.0.1 • Published 2 years ago

console-to-file v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

console-to-file

Logs console.log and console.error to an output text file

const ConsoleToFile = require("console-to-file");

var consoleToFile = new ConsoleToFile("/optional/folder/path"); // default is ./logs


console.log("Foo");
throw new Error("Fee");

// gets logged to 
// /optional/folder/path/11-10-2021 02-30-22 AM.log
// [11/10/2021 02:30:24 AM] [ 'Foo' ]
// [11/10/2021 02:32:15 AM] [
//   '(node:6744) UnhandledPromiseRejectionWarning: Error: Fee\n' +
//     '    at /your/script/path/test.js:33:8\n' +
//     '    at Module._compile (internal/modules/cjs/loader.js:1158:30)\n' +
//     '    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)\n' +
//     '    at Module.load (internal/modules/cjs/loader.js:1002:32)\n' +
//     '    at Function.Module._load (internal/modules/cjs/loader.js:901:14)\n' +
//     '    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)\n' +
//     '    at internal/main/run_main_module.js:18:47'
// ]
1.0.1

2 years ago

1.0.0

2 years ago