express-logs-viewer
v1.0.1
Published
This npm package, express-logs-viewer, provides a simple yet powerful logging solution for Express.js applications. It includes functionality to log various types of messages (e.g., log, error, info, warning) and offers a customizable endpoint for viewin
Downloads
1
Readme
Express Logs Viewer
Overview
This npm package, express-logs-viewer, provides a simple yet powerful logging solution for Express.js applications. It includes functionality to log various types of messages (e.g., log, error, info, warning) and offers a customizable endpoint for viewing, sorting, and managing logs.
Installation
To install express-logs-viewer, you can use npm:
npm install express-logs-viewer
Usage
To use express-logs-viewer in your Express application:
- Import the package and configure function.
- Define a configuration object specifying the desired endpoint, log storage path, authentication credentials (optional), and other preferences.
- Call the configure function with your Express app instance and the configuration object.
Example:
import express from 'express';
import { configure, ExpressLoggerConfig } from 'express-logs-viewer';
const app = express();
const loggerConfig: ExpressLoggerConfig = {
endpoint: '/logs',
path: './logs/',
username: 'admin',
password: 'password',
allowForEnvs: ['development', 'staging'],
logsPerPage: 50,
typeLogs: ['log', 'error'],
logFilePrefix: 'api-',
};
configure(app, loggerConfig);
app.listen(3000, () => {
console.log('Server is running on port 3000');
});
Note
Ensure that the log storage path specified in the configuration object has appropriate write permissions for the application.
For more details on configuration options and usage examples, refer to the inline comments in index.js and helper.ts.