1.0.1 • Published 2 years ago

express-logs-viewer v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

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:

  1. Import the package and configure function.
  2. Define a configuration object specifying the desired endpoint, log storage path, authentication credentials (optional), and other preferences.
  3. 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.