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

laralog

v1.0.0

Published

Laravel-like logging for AdonisJS

Readme

Laralog

npm version npm downloads License: MIT

A simple Laravel-like logging utility for Node.js applications. Developed for AdonisJS but also works well with Express.js and other Node.js frameworks.

Installation

npm i laralog

Usage

Import the logging functions in your Node.js application:

import { log, debug, info, error, warning } from "laralog";

In Exception Handler

AdonisJS Example

Add it to your exception handler in app/exceptions/handler.ts:

import { error } from 'laralog';

// ...

async report(error: unknown, ctx: HttpContext) {
  await error(error);
  return super.report(error, ctx);
}

Express.js Example

Add it to your error handling middleware:

import { error } from "laralog";

// Error handling middleware
app.use((err, req, res, next) => {
  error(err);
  res.status(500).send("Something went wrong");
});

Logging Methods

The library provides several helper methods for different log types:

// Basic logging
await log("User logged in: " + user.email);

// Log with specific types
await debug("Debug information");
await info("User logged in: " + user.email);
await error(new Error("Something went wrong"));
await warning("Disk space is running low");

Using LogType

You can import the LogType to create custom logging functions or type your variables:

import { log, LogType } from "laralog";

// Create a function that accepts a specific log type
function customLogger(message: string, type: LogType) {
  return log(message, type);
}

// Use it with type safety
await customLogger("Database connection established", "info");
await customLogger("Cache miss", "debug");

// Type a configuration object
const logConfig: { level: LogType; persistent: boolean } = {
  level: "warning", // Only "info", "error", "warning", "debug", null, or undefined are allowed
  persistent: true,
};

Log Storage

Logs are stored in a logs directory in the root of your project:

  • When LOG_CHANNEL is set to stack (default): logs/laralog-YYYY-MM-DD.log (daily log files)
  • When LOG_CHANNEL is set to single: logs/laralog.log (single log file)

The logger will automatically create the logs directory if it doesn't exist.

Configuration

Configure the logger using environment variables:

| Variable | Options | Default | Description | | ----------- | ----------------- | ------- | ------------------------------ | | LOG_CHANNEL | stack, single | stack | Determines how logs are stored |

Deprecation Notice

The logToFile method is deprecated and will be removed in the next release. Please use the log method instead.

Links

License

MIT