https://github.com/anthgrim/nodejs-api-logger
NodeJS API Logger
https://github.com/anthgrim/nodejs-api-logger
api javascript logger nodejs npm-package typescript
Last synced: 2 months ago
JSON representation
NodeJS API Logger
- Host: GitHub
- URL: https://github.com/anthgrim/nodejs-api-logger
- Owner: anthgrim
- Created: 2023-01-24T22:19:20.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-26T20:26:20.000Z (over 3 years ago)
- Last Synced: 2025-03-16T02:49:33.437Z (over 1 year ago)
- Topics: api, javascript, logger, nodejs, npm-package, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/nodejs-server-log
- Size: 207 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# NodeJs-server-log
## [nodejs-server-log](https://www.npmjs.com/package/nodejs-server-log)
## Description
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.
### Disclaimer
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
## Installation
Follow the commands bellow
```
cd
npm i nodejs-server-log
```
## How to use?
```JavaScript
import { log } from "nodejs-server-log";
```
## log
log will allow you to log to the console, and write a file with the specific message
```JavaScript
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') })
```
Output:

### readLog
readLogs return a formatted table of the specified logs
```JavaScript
import { readLog } from 'nodejs-server-log'
readLog('error')
```
Output:

## How to contribute
- Fork this repository
- Follow the git commands in your favorite terminal
```bash
git clone git@github.com:/nodejs-api-logger.git
cd nodejs-api-logger
git checkout -b
```
- After adding your changes please commit the new branch and open a PR
```bash
git add
git commit -m
git push origin
```
- Pull Request in GitHub [Pull Request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request)