log-2-route v1.9.2
About The Project
I was looking for an easy-to-use file logger for my Next.js apps, suitable for both development and production, without the need to deploy to Vercel. I tried several popular solutions, but none of them worked well for my use cases, so of course I had to roll my own.
Getting Started
Prerequisites
Installation
Install
npm i log-2-routeConfigure
node ./node_modules/log-2-route/install/configThe config script will perform a few tasks
Configuration
{
"logFile": {
"format": "ndjson",
"enabled": true,
"fileName": "app.log",
"location": "./",
"timeType": "epoch",
"colorizeStyledLog": false
},
"console": {
"format": "styled",
"enabled": true
"timeType": "epoch",
"colorizeStyledLog": true
}
}Logfile Options
Console Options
Usage
Importing
import { logger } from 'log-2-route';Logging
logger.info('messsage');
logger.error('message');
logger.success('message');
logger.debug('message');
logger.warn('message');Example
try {
// codes...
}
catch(e) {
logger.error((e instanceOf Error).message);
logger.debug((e instanceOf Error).stack);
}*logger.debug() will only output to the logfile.
logger.success('User has done a thing!');Logger can take multiple arguments and argument types
logger.info('User logged in', { level: 1 }, 12345);And if set to styled will log
[7378237287] INFO - User logged in level: 1Output
[12/23/2024, 7:40:59 AM] INFO - User Rudy Schneider logged in{"type":"info","time":{"epoch":1734957920354},"data":{"message":"User Rudy Schneider logged in"}}License
Distributed under the MIT. See LICENSE.txt for more information.
Contact
Nathan Schneider - nlschneider@gmail.com
GitHub: [https://github.com/nathanlschneider/log-2-route] NPM: [https://www.npmjs.com/package/log-2-route]
8 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago