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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@magik_io/preset-logging

v1.1.0

Published

Logging middleware preset for Magik (morgan with colorized output)

Readme

@magik_io/preset-logging

Logging middleware preset for Magik featuring beautiful colorized HTTP request logging powered by morgan.

Installation

pnpm add @magik_io/preset-logging

Features

  • 🎨 Beautiful Colorized Output - Eye-catching color schemes for different HTTP methods
  • 🔧 Fully Configurable - Customize colors, formats, and morgan options
  • 🚀 Multiple Formats - Support for morgan's built-in formats or custom functions
  • 🎯 Priority Control - Set middleware execution order
  • 📊 Request Filtering - Skip logging for specific requests

Usage

Quick Start (Default Preset)

Use the default preset with vibrant colorized logging:

import { MagikServer } from '@magik_io/magik';
import { DefaultLoggingPreset } from '@magik_io/preset-logging';

const server = new MagikServer();
server.applyPreset(DefaultLoggingPreset);

Configurable Preset

Customize the logging behavior with the factory function:

import { loggingPreset } from '@magik_io/preset-logging';

// Custom priority
server.applyPreset(loggingPreset({ priority: 80 }));

// Minimal color scheme
server.applyPreset(loggingPreset({ colorScheme: 'minimal' }));

// Monochrome (no colors)
server.applyPreset(loggingPreset({ colorScheme: 'monochrome' }));

// Disable colors completely
server.applyPreset(loggingPreset({ enableColors: false }));

Morgan Built-in Formats

Use any of morgan's standard formats:

// Development format
server.applyPreset(loggingPreset({ format: 'dev' }));

// Apache combined format
server.applyPreset(loggingPreset({ format: 'combined' }));

// Apache common format
server.applyPreset(loggingPreset({ format: 'common' }));

// Short format
server.applyPreset(loggingPreset({ format: 'short' }));

// Minimal format
server.applyPreset(loggingPreset({ format: 'tiny' }));

Advanced Options

Skip Certain Requests

server.applyPreset(loggingPreset({
  skip: (req, res) => res.statusCode < 400 // Only log errors
}));

Custom Output Stream

import * as fs from 'node:fs';
import * as path from 'node:path';

const accessLogStream = fs.createWriteStream(
  path.join(__dirname, 'access.log'),
  { flags: 'a' }
);

server.applyPreset(loggingPreset({
  stream: accessLogStream
}));

Immediate Logging

Log requests immediately instead of on response:

server.applyPreset(loggingPreset({
  immediate: true
}));

Custom Format Function

Create your own custom logging format:

server.applyPreset(loggingPreset({
  format: (tokens, req, res) => {
    return [
      tokens.method(req, res),
      tokens.url(req, res),
      tokens.status(req, res),
      tokens['response-time'](req, res), 'ms'
    ].join(' ');
  }
}));

Combining Multiple Options

server.applyPreset(loggingPreset({
  priority: 90,
  colorScheme: 'minimal',
  skip: (req, res) => req.url?.startsWith('/health'),
  immediate: false
}));

Color Schemes

Default

Vibrant color schemes with background colors for each HTTP method:

  • GET: Blue on Purple
  • POST: Pink on Cyan
  • PUT: Yellow on Gray
  • DELETE: Red on Gray
  • PATCH: Orange on Black
  • Others: Yellow on Red

Minimal

Simple, clean colors using standard chalk colors:

  • Methods in blue
  • Status codes colored by type (green for 2xx, yellow for 3xx, red for 4xx/5xx)
  • URLs in cyan
  • Response times in gray

Monochrome

Plain text output without any colors, useful for production logs or file outputs.

API

loggingPreset(options?: LoggingOptions): MiddlewarePreset

Factory function to create a customized logging preset.

Options

interface LoggingOptions extends morgan.Options {
  priority?: number;                    // Middleware priority (default: 95)
  format?: MorganFormat | FormatFn;     // Log format (default: 'colorized')
  colorScheme?: ColorScheme;            // Color scheme (default: 'default')
  enableColors?: boolean;               // Enable/disable colors (default: true)
  immediate?: boolean;                  // Log on request instead of response
  skip?: (req, res) => boolean;        // Skip logging for certain requests
  stream?: NodeJS.WritableStream;      // Output stream (default: stdout)
}

type ColorScheme = 'default' | 'minimal' | 'monochrome';
type MorganFormat = 'combined' | 'common' | 'dev' | 'short' | 'tiny' | 'colorized';

DefaultLoggingPreset: MiddlewarePreset

Pre-configured preset with the default colorized format at priority 95.

License

MIT