npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

log-express

v1.0.2

Published

log-express is a lightweight and customizable middleware for Express.js that provides comprehensive logging of all incoming user requests. Designed to be easy to integrate and configure, this package helps you keep track of request details, which can be i

Downloads

4

Readme

log-express

log-express is a lightweight and customizable middleware for Express.js that provides comprehensive logging of all incoming user requests. Designed to be easy to integrate and configure, this package helps you keep track of request details, which can be invaluable for debugging, monitoring, and analyzing traffic patterns.

Features

  • Customizable Logging: Choose log levels, enable file logging, and more.
  • Console and File Logging: Logs can be sent to the console and/or saved to files.
  • Daily Log Rotation: Optional daily log file creation.
  • Detailed Request Information: Logs request method, URL, status code, response time, and client IP.

Installation

To install log-express, use npm:

npm install log-express

Usage

Basic Setup

To use log-express in your Express application, follow these steps:

  1. Create a new Express application or open an existing one.
  2. Install the log-express package.
  3. Configure and use the middleware in your application.
const express = require("express");
const log-express = require("log-express"); // Adjust this if the package name is different

const app = express();

// Configure the middleware
const loggerOptions = {
  logLevel: "debug", // Adjust log level: trace, debug, info, warn, error, fatal
  consoleLog: true, // Set to false to disable console logging
  saveLogs: true, // Set to true to enable file logging
  logPerDay: true, // Set to true to enable logging per day (e.g., logs/system-2024-09-05.logs)
};

// Use the middleware
app.use(log-express(loggerOptions));

// Define routes
app.get("/", (req, res) => {
  res.send("Welcome to the home page!");
});

app.get("/about", (req, res) => {
  res.send("About us page");
});

// Start the server
app.listen(3000, () => {
  console.log("Server started at http://localhost:3000");
});

Middleware Options

  • logLevel: Set the logging level. Options: trace, debug, info, warn, error, fatal.
  • consoleLog: true to log to the console, false to disable console logging.
  • saveLogs: true to save logs to a file, false otherwise.
  • logPerDay: true to create a new log file each day, false to use a single file.

Contributing

We welcome contributions to log-express. If you'd like to contribute, please follow these steps:

  1. Fork the repository: Click on the "Fork" button at the top right of this page.

  2. Clone your fork:

    git clone https://github.com/piyushPb/log-express.git
  3. Create a new branch:

    git checkout -b feature-branch
  4. Make your changes and commit them:

    git add .
    git commit -m "Add new feature"
  5. Push to your fork:

    git push origin feature-branch
  6. Create a pull request: Go to the original repository and create a pull request from your fork's branch.

For detailed guidelines, please refer to our CONTRIBUTING.md file.

License

log-express is licensed under the MIT License. See the LICENSE file for more information.

Acknowledgements

  • Express.js: The framework that log-express extends.
  • Contributors: Thanks to all contributors who have helped improve the project.

Contact

For questions or support, please open an issue on GitHub.