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

@uptime-cli/logger

v1.0.0

Published

Logger package for Uptime Monitor - send application logs to Uptime Monitor API

Downloads

7

Readme

@uptime/logger

Logger package for Uptime Monitor - send application logs to Uptime Monitor API and trigger alerts based on log severity.

Installation

npm install @uptime/logger

Quick Start

import { UptimeLogger } from '@uptime/logger';

// Initialize with your service token from Uptime Monitor dashboard
const logger = new UptimeLogger({
  token: 'upt_abc123...xyz789',
  serviceName: 'user-service'
});

// Log at different levels
logger.error('Database connection failed');
logger.warn('High memory usage detected');
logger.info('User logged in', { userId: '123' });
logger.debug('Processing request', { requestId: 'req-456' });

Configuration

Basic Configuration

const logger = new UptimeLogger({
  token: 'your-service-token',  // Required: Get from Uptime Monitor dashboard
  serviceName: 'my-service',     // Optional: Service identifier
  baseUrl: 'https://api.example.com', // Optional: API base URL
  enabled: true,                 // Optional: Enable/disable logging
  environment: 'production'      // Optional: Environment identifier
});

Environment Variables

You can use environment variables for configuration:

const logger = new UptimeLogger({
  token: process.env.UPTIME_TOKEN,
  baseUrl: process.env.UPTIME_API_URL, // Optional, defaults to current origin
});

Usage Examples

Basic Logging

logger.error('Payment processing failed');
logger.warn('API rate limit approaching');
logger.info('Cache updated successfully');
logger.debug('Query executed', { query: 'SELECT * FROM users' });

With Metadata

logger.error('Transaction failed', {
  transactionId: 'txn-123',
  amount: 100.50,
  userId: 'user-456'
});

Child Loggers (Context)

Create child loggers with persistent context:

const requestLogger = logger.child({ 
  requestId: 'req-789',
  userId: 'user-123'
});

// All logs from requestLogger will include requestId and userId
requestLogger.error('Validation failed');
requestLogger.info('Request completed');

Express Middleware Example

import express from 'express';
import { UptimeLogger } from '@uptime/logger';

const logger = new UptimeLogger({
  token: process.env.UPTIME_TOKEN,
  serviceName: 'express-api'
});

const app = express();

app.use((req, res, next) => {
  const requestLogger = logger.child({ 
    requestId: req.id,
    path: req.path,
    method: req.method
  });
  
  req.logger = requestLogger;
  next();
});

app.post('/users', async (req, res) => {
  try {
    const user = await createUser(req.body);
    req.logger.info('User created', { userId: user.id });
    res.json(user);
  } catch (error) {
    req.logger.error('Failed to create user', { 
      error: error.message,
      stack: error.stack 
    });
    res.status(500).json({ error: 'Internal server error' });
  }
});

Error Handling

try {
  await processPayment();
  logger.info('Payment processed successfully');
} catch (error) {
  logger.error('Payment processing failed', {
    error: error.message,
    stack: error.stack,
    orderId: order.id
  });
}

API Reference

UptimeLogger

Constructor

new UptimeLogger(config: LoggerConfig)

Config Options:

  • token (required): Service token from Uptime Monitor dashboard
  • serviceName (optional): Service identifier
  • baseUrl (optional): API base URL (defaults to UPTIME_API_URL env var or current origin)
  • enabled (optional): Enable/disable logging (default: true)
  • environment (optional): Environment identifier

Methods

  • error(message: string, metadata?: LogMetadata): void - Log error level
  • warn(message: string, metadata?: LogMetadata): void - Log warning level
  • info(message: string, metadata?: LogMetadata): void - Log info level
  • debug(message: string, metadata?: LogMetadata): void - Log debug level
  • child(context: LogMetadata): UptimeLogger - Create child logger with context

Log Levels

Log levels are ordered by severity:

  • debug (lowest) - Detailed debugging information
  • info - General informational messages
  • warn - Warning messages
  • error (highest) - Error messages

Configure alert thresholds in Uptime Monitor dashboard to control which log levels trigger alerts.

How It Works

  1. Initialize logger with your service token
  2. Log messages using error(), warn(), info(), or debug() methods
  3. Logs are sent to /api/logs/ingest endpoint
  4. Alerts trigger when log level meets your configured threshold
  5. Notifications are sent via email, Slack, or webhooks

Notes

  • Logs are sent asynchronously (non-blocking)
  • Failed API calls are logged to console but don't throw errors
  • Child loggers merge context with individual log metadata
  • All logs include automatic timestamps

License

MIT