borgen v2.0.0
Borgen🏅 (The developers👨💻 logger)
The custom Logger for your Node-Express app.
A HTTP request logger middleware for nodeJs

Installation🏗️
This is a Node.js module available through the
npm registry. Installation is done using the
npm install command:
$ npm i borgenIf you use yarn:
$ yarn add borgenIf you use pnpm:
$ pnpm add borgen🚀Usage
const { Logger, Borgen } = require('borgen');import { Logger,Borgen } from 'borgen';Basic use
This is the simplest way you can use Borgen, you can however customize \ the colors it uses in logging.
const express = require('express');
const { Logger, Borgen } = require('borgen');
const app = express();
app.use(Borgen({}))
Logger.info({message: 'This is an informational message.'});
Logger.warn({message:'This is a warning message.'});
Logger.error({message:'This is an error message.'})
app.listen('3002', () => {
Logger.info({ message: 'The server is running on port 3002'});
});
Available Customizations: 🌞Colors
blackredgreenyellowbluemagentacyanwhiteblackBright(alias:gray,grey)redBrightgreenBrightyellowBrightblueBrightmagentaBrightcyanBrightwhiteBright
Logger💬
Basic usage
Logger.info({message: 'This is an informational message.'});
Logger.warn({message:'This is a warning message.'});
Logger.error({message:'This is an error message.'})
Customizing the Colors🧰
You can fully customize the color for your log.
Logger has three options:
- Logger.info( )
- Logger.warn( )
- Logger.error( )
Each Logger option has defaults and will fallback if no arguments are passed
const express = require('express');
const { Logger, Borgen } = require('borgen');
const app = express();
app.get('/test', (req, res) => {
Logger.warn({ message: 'This is an warning', infoColor: 'yellow', messageColor: 'yellowBright' });
res.send('Hello world').end();
});
app.get('*', (req, res) => {
Logger.error({ message: 'This route does not exist', infoColor: 'red', messageColor: 'redBright' });
res.send('404 not found');
});
app.listen('3001', () => {
Logger.info({ message: 'The server is running on port 3001', infoColor: 'cyanBright', messageColor: 'whiteBright' });
});
Logger arguments💥
messageThis is the information you want to be logged to the console.infoColorThis is the color of the first section of the log.messageColorThis is will be the color of the message you want to log.
Note: infoColor and messageColor are optional and if not passed the logger will\ will use the fallback configuration.
Use CTRL + space or Options + space with infoColor and messageColor to get all\
the colors available.
Borgen middleware
This middleware is able to handle all you incoming requests and you can \ customize the colors they are logged in.
Basic use
app.use(Borgen({}))
🧰Customizing the Colors
You can fully customize the color for your incoming requests.
const express = require('express');
const { Logger, Borgen } = require('borgen');
const app = express();
app.use(
Borgen({
methodColor: {
GET: 'greenBright',
POST: 'yellow',
PUT: 'gray',
PATCH: 'gray',
DELETE: 'redBright'
},
routeColor: 'gray',
statusColor: 'cyan',
resTimeColor: 'gray',
statusCodesCl: { serverErr: 'red', clientErr: 'yellow', redirects: 'cyan', success: 'greenBright' }
})
);
app.listen('3001', () => {
Logger.info({ message: 'The server is running on port 3001', infoColor: 'cyanBright', messageColor: 'whiteBright' });
});
Borgen arguments💥
methodColorit is an Object which allows you to specify a specific color for different request types.routeColorit is the color of the route of the request e.g /api/v1/users.statusColorit is the color of the status textresTimeColorit is the color of how long it took the request to process and give a response.statusCodesClit is where you specify the color of status codes in different rangesserverErrfor 5xxclientErrfor 4xxredirectsfor 3xxsuccessfor 2xx
Note: All this arguments are optional and if not passed the logger will\ will use the fallback configuration.
Save my logs🚀
Using this feature you can store you apps log in a file.\ This feature is useful for debugging and for production.
📑Borgen logs 🐾
logs argument allows you to specify a path where your log file will be located.
app.use(
Borgen({
logs: '../logs/borgen.log'
})
);📑Logger logs 🐾
To save your logs you need to add the logs parameter as an argument.
Logger.info({ logs: '../logs/info.log' });
Logger.warn({ logs: '../logs/warnings.log' });
Logger.error({ logs: '../logs/error.log' });\ Note: The 🔖log file name can be any custom name. ' ./custom_name.log '
💪🏽 Thanks to all the awesome Contributors
Thanks a lot for spending your time helping Borgen grow. Thanks a lot! Keep rocking🍻