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

@mesalvo/logger

v0.0.41487

Published

Centralized logging system with optional UI and React hooks for Mesalvo applications

Readme

@mesalvo/logger

Centralized logging system with optional UI and React hooks for Mesalvo applications.

📦 Installation

pnpm add @mesalvo/logger

🚀 Basic Usage

Simple logging (without React)

import { log } from '@mesalvo/logger';

log.info('User authenticated');
log.error('Error loading data', { endpoint: '/api/users' });
log.warn('Validation warning');
log.debug('State updated', { newState });

With custom configuration

import { Logger } from '@mesalvo/logger';

const logger = Logger.getInstance({
  appId: 'my-app',
  appVersion: '1.0.0',
  minLevel: 'info',
  maxStoredLogs: 500,
  showToastOnError: true,
});

logger.info('App started');

With React Hooks

import { useLogger } from '@mesalvo/logger';

function DebugPage() {
  const { logs, stats, clearLogs, exportLogs, refresh } = useLogger();
  
  return (
    <div>
      <p>Total logs: {stats.total}</p>
      <p>Errors: {stats.byLevel.error}</p>
      <button onClick={clearLogs}>Clear</button>
      <button onClick={exportLogs}>Export</button>
    </div>
  );
}

With Full UI (requires @mesalvo/react-ui)

import { useLogger, LogViewer} from '@mesalvo/logger';

function DebugPanel() {
  const { logs, clearLogs, exportLogs } = useLogger();
  
  return (
    <LogViewer 
      logs={logs}
      onClear={clearLogs}
      onExport={exportLogs}
      maxHeight="600px"
    />
  );
}

Full panel with statistics

import { useLogger } from '@mesalvo/logger';
import { LogsDebugPanel } from '@mesalvo/logger';

function FullDebugPage() {
  const { logs, stats, clearLogs, exportLogs } = useLogger();
  
  return (
    <LogsDebugPanel 
      logs={logs}
      stats={stats}
      onClear={clearLogs}
      onExport={exportLogs}
    />
  );
}

Global initialization with error handlers

import { useLoggerInit } from '@mesalvo/logger';

function App() {
  useLoggerInit(); // Setup global error handlers
  return <YourApp />;
}

Toast integration (optional)

import { setToastHandler } from '@mesalvo/logger';
import { toast } from '@mesalvo/react-ui';

// In your app initialization
setToastHandler(toast);

🎯 Features

Core (always available)

  • ✅ 4 log levels (debug, info, warn, error)
  • ✅ localStorage persistence
  • ✅ Stack trace capture
  • ✅ Context enrichment (user, URL, session)
  • ✅ JSON export
  • ✅ Advanced filtering
  • ✅ Log statistics
  • ✅ Full TypeScript support

React (optional)

  • useLogger hook to access logs
  • useLoggerInit hook for global setup
  • ✅ Auto-refresh logs

UI (optional - requires @mesalvo/react-ui)

  • LogViewer component to display logs
  • LogsDebugPanel component with statistics
  • ✅ Filter by level
  • ✅ Text search
  • ✅ JSON export

📁 Export Structure

// Core
import { Logger, log, LogLevel, setToastHandler } from '@mesalvo/logger';

// React hooks
import { useLogger, useLoggerInit } from '@mesalvo/logger';

// UI Components (requires @mesalvo/react-ui)
import { LogViewer, LogsDebugPanel } from '@mesalvo/logger';

🔧 API

Logger

const logger = Logger.getInstance(config);

logger.debug(message, data?);
logger.info(message, data?);
logger.warn(message, data?);
logger.error(message, error?);

logger.getLogs(): LogEntry[];
logger.getFilteredLogs(filter): LogEntry[];
logger.getStats(): LogStats;
logger.clearLogs(): void;
logger.exportLogs(filter?): void;
logger.configure(config): void;

useLogger Hook

const {
  logs,        // LogEntry[]
  stats,       // LogStats
  clearLogs,   // () => void
  exportLogs,  // () => void
  refresh,     // () => void
} = useLogger(filter?);

📝 Types

enum LogLevel {
  DEBUG = "debug",
  INFO = "info",
  WARN = "warn",
  ERROR = "error",
}

interface LogEntry {
  id: string;
  timestamp: number;
  level: LogLevel;
  message: string;
  data?: Record<string, unknown>;
  context: LogContext;
  stackTrace?: string;
  source?: SourceLocation;
}

interface LoggerConfig {
  appId: string;
  appVersion: string;
  minLevel: LogLevel;
  maxStoredLogs: number;
  enableConsole: boolean;
  enableStorage: boolean;
  showToastOnError: boolean;
  showToastOnWarn: boolean;
  captureSourceLocation: boolean;
  environment: string;
}

🧪 Testing

The package includes utilities for testing:

import { createMockLogger, setupLoggerForTests, resetLoggerForTests } from '@mesalvo/logger';

beforeEach(() => {
  setupLoggerForTests();
});

afterEach(() => {
  resetLoggerForTests();
});

📦 Dependencies

Core

  • No external dependencies

React

  • react (peer dependency)

Components

  • react (peer dependency)
  • @mesalvo/react-ui (peer dependency, optional)

📄 License

ISC © Mesalvo GmbH