Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
koa-colorful-logger
Advanced tools
A middleware for koa that can log colorful request info automatically. And you can also use it as a normal logger.
A middleware for koa that can log colorful request info automatically. And you can also use it as a normal logger.
$ npm install -S koa-colorful-logger
const Koa = require('koa');
const Logger = require('koa-colorful-logger');
const app = new Koa();
const logger = new Logger({
/**
* Should output logger info to file
* Default: false
*/
output: true,
/**
* Where is log file in
* Default: `./logs`
*/
outputDir: './logs',
/**
* Only when level exceed your setting will log info be output.
* Priority: DEBUG < INFO < WARNING < ERROR < CRITICAL
*/
outputLevel: 'INFO',
/**
* The format of the prefix.
* Default is: '[level][time] '
* Available variables:
* - [level]
* - [time]
*/
prefixFormat: '[level][time] ',
/**
* A function that should return a string for message.
* It will receive two args: 'ctx` and 'costTime'.
* Default is:
* ```javascript
* function (ctx, costTime) {
* return `${ctx.method} ${ctx.originalUrl} - ${ctx.status} - ${costTime}ms - ${ctx.ip}`;
* }
* ```
*/
msgFormatFunction: function (ctx, costTime) {
return `${ctx.method} ${ctx.originalUrl} - ${ctx.status} - ${costTime}ms - ${ctx.ip}`;
}
})
app.use(logger.middleware());
app.listen(4000);
You can use these api below to output your message.
logger.debug(msg);
logger.info(msg);
logger.warning(msg);
logger.error(msg);
logger.critical(msg);
/**
* Param bodyColorFunc should be chalk.ChalkFunction
*/
logger.log(level, bodyColorFunc, msg);
FAQs
security holding package
The npm package koa-colorful-logger receives a total of 4 weekly downloads. As such, koa-colorful-logger popularity was classified as not popular.
We found that koa-colorful-logger demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.