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

@yigityalim/logger

v0.5.0

Published

Lightweight, flexible logging library with multiple transports and formatters for Node.js and Next.js

Readme

@yigityalim/logger

Structured logging package.

Features

  • Log Levels: debug, info, warn, error
  • Multiple Formatters: JSON, Pretty, Structured
  • Context Propagation: Child loggers with inherited context
  • Performance Monitoring: Track operation duration
  • Log Aggregation: Collect and analyze logs
  • Log Retention: Automatic cleanup with policies
  • File Transport: Write logs to files with rotation
  • Sentry Integration: Error tracking for Next.js and Expo
  • Environment-Aware: Auto-configures based on NODE_ENV
  • Type-Safe: Full TypeScript support
  • Zero Config: Works out of the box

Installation

# Already available in monorepo
import { createLogger } from '@yigityalim/logger';

Usage

Basic Usage

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

const logger = createLogger({
  name: 'api',
});

logger.info('Server started', { port: 3000 });
logger.error('Database error', new Error('Connection failed'));

With Context (Child Loggers)

const logger = createLogger({ name: 'api' });

// Create child logger with context
const userLogger = logger.child({ userId: 'user-123' });

userLogger.info('User logged in');
// Output: [timestamp] [INFO] User logged in context={"userId":"user-123"}

userLogger.info('Profile updated', { field: 'email' });
// Output: [timestamp] [INFO] Profile updated context={"userId":"user-123"} metadata={"field":"email"}

Log Levels

logger.debug('Debug message');  // Only in development
logger.info('Info message');    // General information
logger.warn('Warning message'); // Warning
logger.error('Error message', new Error('Something went wrong'));

Custom Configuration

const logger = createLogger({
  name: 'api',
  level: 'info',      // Minimum log level
  format: 'json',     // json | pretty | structured
  enabled: true,      // Enable/disable logging
  context: {          // Default context
    service: 'api',
    version: '1.0.0',
  },
});

Formatters

Pretty (Development)

17:32:45.123 INFO  Server started [{"port":3000}]

JSON (Production)

{"timestamp":"2025-01-30T17:32:45.123Z","level":"info","message":"Server started","metadata":{"port":3000}}

Structured

[2025-01-30T17:32:45.123Z] [INFO] Server started metadata={"port":3000}

Environment Variables

NODE_ENV=production  # Auto-selects JSON format and 'info' level
NODE_ENV=development # Auto-selects Pretty format and 'debug' level

Examples

API Server

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

const logger = createLogger({ name: 'api' });

app.listen(3000, () => {
  logger.info('Server started', { port: 3000 });
});

app.use((err, req, res, next) => {
  logger.error('Request failed', err);
  res.status(500).json({ error: 'Internal server error' });
});

Job Processing

const logger = createLogger({ name: 'jobs' });

async function processJob(jobId: string) {
  const jobLogger = logger.child({ jobId });
  
  jobLogger.info('Job started');
  
  try {
    // Process job
    jobLogger.info('Job completed');
  } catch (error) {
    jobLogger.error('Job failed', error);
  }
}

User Actions

const logger = createLogger({ name: 'app' });

function handleUserAction(userId: string, action: string) {
  const userLogger = logger.child({ userId });
  
  userLogger.info('User action', { action });
}

Best Practices

  1. Use Child Loggers: Create child loggers with context for better traceability
  2. Include Metadata: Add relevant metadata to log entries
  3. Use Appropriate Levels:
    • debug: Detailed debugging information
    • info: General informational messages
    • warn: Warning messages
    • error: Error messages with stack traces
  4. Sanitize Sensitive Data: Never log passwords, tokens, or PII

License

MIT