consoletolog

A dependency to save your js console logs to a file with Node JS

Example

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

Be creative!

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'  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜