A dependency to save your js console logs to a file with Node JS
npm i consoletolog
ctl --name=cool-process
That will create a directory tree, change your package.json, and will output something like this
_ _ _
___ ___ _ __ ___ ___ | | ___| |_ ___ | | ___ __ _
/ __/ _ \| '_ \/ __|/ _ \| |/ _ \ __/ _ \| |/ _ \ / _ |
| (_| (_) | | | \__ \ (_) | | __/ || (_) | | (_) | (_| |
\___\___/|_| |_|___/\___/|_|\___|\__\___/|_|\___/ \__, |
|___/
Proceso creado!
Run the process as - npm run cool-process
βββ cool-process
βββ logs
βββ run.js
βββ cool-process.js
package.json
"scripts": {
"cool-process": "node ./cool-process/run.js"
}
Then, after running that command it will add a log file
βββ cool-process
βββ logs
β βββ 21-08-2020_09-58-51.txt
βββ run.js
βββ cool-process.js
You can get creative with the logs to get a cool output
// cool-process.js
var users = [
{ name: 'Nicolas', lastName: 'Guillen' },
{ name: 'Mariano', lastName: 'Rivera' },
]
console.table(users)
After running that process youβd get a table like this
βββββββββββ¬ββββββββββββ¬ββββββββββββ
β (index) β name β lastName β
βββββββββββΌββββββββββββΌββββββββββββ€
β 0 β 'Nicolas' β 'Guillen' β
β 1 β 'Mariano' β 'Rivera' β
βββββββββββ΄ββββββββββββ΄ββββββββββββ