This is a small package for logging purposes. It logs to the console and writes a file of the specific log in a ./logs directory in the root folder.
As of now, the levels of log are the following: info, database, error, fatal, debug, and access. We will be working on make it more customizable in future releases
Follow the commands bellow
cd <YourProjectName>
npm i nodejs-server-log
import { log } from "nodejs-server-log";
log will allow you to log to the console, and write a file with the specific message
log({ levelName: 'debug', message: 'Debugging log' })
log({ levelName: 'access', message: 'Access log' })
log({ levelName: 'database', message: 'Database log' })
log({ levelName: 'info', message: 'Info log' })
log({ levelName: 'error', message: '', error: new Error('General error') })
log({ levelName: 'fatal', message: '', error: new Error('Fatal error') })
readLogs return a formatted table of the specified logs
import { readLog } from 'nodejs-server-log'
readLog('error')
- Fork this repository
- Follow the git commands in your favorite terminal
git clone [email protected]:<githubUsername>/nodejs-api-logger.git cd nodejs-api-logger git checkout -b <NameYourNewBranch>
- After adding your changes please commit the new branch and open a PR
git add <YourChanges> git commit -m <Your changes comments> git push origin <Your branch name>
- Pull Request in GitHub Pull Request