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

@veksa/logger

v1.0.12

Published

Lightweight, configurable logging library for JavaScript applications

Downloads

79

Readme

@veksa/logger

npm version npm downloads license

Lightweight, configurable logging library for JavaScript applications

Installation

@veksa/logger requires TypeScript 5.8 or later.

Using npm or yarn

# npm
npm install @veksa/logger

# yarn
yarn add @veksa/logger

Features

  • Enhanced console logging with timestamps
  • Memory storage of logs with automatic expiration (10 minutes by default)
  • Special formatting for requests, responses, and events
  • Easy enabling/disabling of logging
  • Support for restricting specific message IDs
  • Colorized console output
  • Generic type support for type-safe message handling
  • Utility functions for log management

Basic Usage

import { createLogger } from '@veksa/logger';

// Create logger (enabled by default)
const logger = createLogger(true);

// Basic logging
logger.info('Application started');
logger.warn('Resource is running low');
logger.error('Failed to connect', { code: 500 });

// Network message logging
logger.request({
  id: 'GET_USER',
  payload: { userId: 123 },
  clientMsgId: 'abc-123'
}, {
  prefix: 'API',
  messageName: 'GetUser'
});

logger.response({
  id: 'GET_USER',
  payload: { user: { id: 123, name: 'John' } },
  clientMsgId: 'abc-123'
}, {
  prefix: 'API',
  messageName: 'GetUser'
});

// Get all stored logs
const logs = logger.getLogs();

// Disable logging
logger.disable();

// Enable logging
logger.enable();

API Reference

createLogger<Message>(isEnabled, isRestricted?)

Creates a new logger instance.

  • isEnabled (boolean): Whether logging is initially enabled
  • isRestricted (function): Optional function that determines if a message ID should be restricted from logging

Returns an ILogger<Message> object with the following methods:

Methods

  • enable(): Enable console output
  • disable(): Disable console output
  • getLogs(): Get array of stored log items
  • info(text, ...causes): Log informational message
  • error(text, ...causes): Log error message
  • warn(text, ...causes): Log warning message
  • request(item, meta?): Log request with optional metadata
  • response(item, meta?): Log response with optional metadata
  • event(item, meta?): Log event with optional metadata

Interfaces

interface ILogItem {
    timestamp: number;
    message: string;
}

interface IMessage<Payload = unknown> {
    id?: string | number;
    payload: Payload;
    clientMsgId: string;
}

interface IMessageMeta {
    prefix?: string;
    prefixColor?: string;
    messageName?: string;
}

interface ILogger<Message extends IMessage> {
    enable: () => void;
    disable: () => void;
    getLogs: () => ILogItem[];
    info: (text: string, ...causes: unknown[]) => void;
    error: (text: string, ...causes: unknown[]) => void;
    warn: (text: string, ...causes: unknown[]) => void;
    request: (item: Message, meta?: IMessageMeta) => void;
    response: (item: Message, meta?: IMessageMeta) => void;
    event: (item: Message, meta?: IMessageMeta) => void;
}

Helper Functions

mergeLogs(limit)

Merges multiple log arrays into a single array, sorted by timestamp.

  • limit (number): Maximum number of log messages to return
import { createLogger, mergeLogs } from '@veksa/logger';

const logger1 = createLogger(true);
const logger2 = createLogger(true);

// Get combined logs from both loggers, limited to 100 entries
const combinedLogs = mergeLogs(100)(logger1.getLogs(), logger2.getLogs());

Contributing

This project welcomes contributions and suggestions.

License

MIT