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 🙏

© 2025 – Pkg Stats / Ryan Hefner

log-2-route

v1.11.4

Published

Logger for NextJS that uses the app router to enable logging from anywhere in your app and beyond.

Downloads

1,040

Readme

About The Project

I was looking for an easy-to-use file logger for my Next.js apps, suitable for both development and production, without the need to deploy to Vercel. I tried several popular solutions, but none of them worked well for my use cases, so of course I had to roll my own.

Getting Started

Prerequisites

Installation

Install

npm i log-2-route

Configure

node ./node_modules/log-2-route/install/config

The config script will perform a few tasks

Configuration

{
    "logFile": {
      "format": "ndjson",
      "enabled": true,
      "fileName": "app.log",
      "location": "./",
      "timeType": "epoch",
      "colorizeStyledLog": false
    },
    "console": {
      "format": "styled",
      "enabled": true
      "timeType": "epoch",
      "colorizeStyledLog": true
    }
  }

Logfile Options

Console Options

Usage

Importing

import { logger } from 'log-2-route';

Logging

logger.info('messsage');
logger.error('message');
logger.success('message');
logger.debug('message');
logger.warn('message');

Example

try {
  // codes...
}
catch(e) {
  logger.error((e instanceOf Error).message);
  logger.debug((e instanceOf Error).stack);
}

*logger.debug() will only output to the logfile.

logger.success('User has done a thing!');

Logger can take multiple arguments and argument types

logger.info('User logged in', { level: 1 }, 12345);

You must wrap the logger in a useEffect hook when using client side

useEffect(()=> logger.info("Logged."), [])

And if set to styled will log

[7378237287] INFO - User logged in level: 1

Output

[12/23/2024, 7:40:59 AM] INFO - User Rudy Schneider logged in
{"type":"info","time":{"epoch":1734957920354},"data":{"message":"User Rudy Schneider logged in"}}

License

Distributed under the MIT. See LICENSE.txt for more information.

Contact

Nathan Schneider - nlschneider@gmail.com

GitHub: [https://github.com/nathanlschneider/log-2-route] NPM: [https://www.npmjs.com/package/log-2-route]