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

@tgtone/logger

v1.2.0

Published

Debug logger utility for TGT One projects

Readme

@tgtone/logger

Debug logger utility for TGT One projects with environment-based control

Features

  • Environment-aware: Control via VITE_LOG_LEVELS (browser) or LOG_LEVELS (Node.js)
  • Browser & Node.js compatible: Works in both environments without polyfills
  • Multiple log levels: debug, info, warn, error
  • Namespace support: Organize logs by module/service
  • Child loggers: Create nested loggers that inherit configuration
  • Timestamp support: Optional ISO timestamp in each log
  • Production-safe: Control exactly which levels to show
  • Zero dependencies: Lightweight and fast
  • TypeScript: Fully typed
  • Vite-ready: No define config needed

Installation

npm install @tgtone/logger

Quick Start

Basic Usage

import { debug, info, warn, error } from '@tgtone/logger';

debug('🐛 Debug information');           // Shows if 'debug' in VITE_LOG_LEVELS
info('ℹ️ Important information');        // Shows if 'info' in VITE_LOG_LEVELS
warn('⚠️ Warning message');              // Shows if 'warn' in VITE_LOG_LEVELS
error('❌ Error occurred');              // Shows if 'error' in VITE_LOG_LEVELS

With Namespace

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

const logger = new Logger({ namespace: 'AuthService' });

logger.debug('Token validation started');
// 🐛 [AuthService] Token validation started

logger.info('User logged in:', user.email);
// ℹ️ [AuthService] User logged in: [email protected]

With Timestamp

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

const logger = new Logger({ namespace: 'API', timestamp: true });

logger.debug('Request received');
// [2024-01-15T10:30:00.000Z] 🐛 [API] Request received

Child Loggers

const authLogger = new Logger({ namespace: 'Auth' });
const jwtLogger = authLogger.child('JWT');

jwtLogger.debug('Verifying token');
// 🐛 [Auth:JWT] Verifying token

Configuration

Environment Variables

Control log levels via environment variables:

| Variable | Environment | Example | |----------|-------------|---------| | VITE_LOG_LEVELS | Browser (Vite) | VITE_LOG_LEVELS=debug,info | | LOG_LEVELS | Node.js | LOG_LEVELS=warn,error |

Log Level Values

| Valor | Resultado | |-------|-----------| | * o no definido | Todos los niveles habilitados | | debug,info,warn | Solo debug, info y warn | | error | Solo errores | | none | Deshabilita todos los niveles |

Browser Usage (React/Vue/Svelte with Vite)

# .env.local
VITE_LOG_LEVELS=*           # Todos los niveles (desarrollo)
VITE_LOG_LEVELS=error       # Solo errores (producción)
VITE_LOG_LEVELS=debug,info  # Solo debug e info
import { Logger } from '@tgtone/logger';

// El logger lee automáticamente VITE_LOG_LEVELS
const logger = new Logger({ namespace: 'MyApp' });

logger.debug('This shows if debug is enabled');

Node.js Usage (Backend/NestJS/Express)

# Development
LOG_LEVELS=* npm run start

# Production
LOG_LEVELS=error npm run start:prod
import { Logger } from '@tgtone/logger';

// El logger lee automáticamente LOG_LEVELS
const logger = new Logger({ namespace: 'AuthService' });

Programmatic Config

import { Logger, LogLevel } from '@tgtone/logger';

const logger = new Logger({
  namespace: 'MyService',     // Add namespace prefix
  emojis: true,               // Enable emojis (default: true)
  timestamp: true,            // Show ISO timestamp (default: false)
  minLevel: LogLevel.INFO,    // Minimum log level (fallback)
  allowedLevels: [LogLevel.DEBUG, LogLevel.INFO], // Specific levels
});

Log Levels

import { LogLevel } from '@tgtone/logger';

LogLevel.DEBUG  // 🐛 Debug information
LogLevel.INFO   // ℹ️ General information
LogLevel.WARN   // ⚠️ Warnings
LogLevel.ERROR  // ❌ Errors
LogLevel.NONE   // 🚫 Disable all logs

API Reference

Logger

class Logger {
  constructor(config?: LoggerConfig)
  
  debug(...args: any[]): void
  info(...args: any[]): void
  warn(...args: any[]): void
  error(...args: any[]): void
  
  child(namespace: string): Logger
  isDebugEnabled(): boolean
}

LoggerConfig

interface LoggerConfig {
  namespace?: string;           // Prefix for all logs
  emojis?: boolean;             // Show emojis (default: true)
  timestamp?: boolean;          // Show ISO timestamp (default: false)
  minLevel?: LogLevel;          // Minimum level (default: DEBUG)
  allowedLevels?: LogLevel[];   // Specific allowed levels
}

Helper Functions

import { debug, info, warn, error, defaultLogger } from '@tgtone/logger';

// Use default logger directly
debug('Message');
info('Message');
warn('Message');
error('Message');

// Or access the default logger instance
defaultLogger.debug('Message');

Use Cases

NestJS Services

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

export class AuthService {
  private logger = new Logger({ namespace: 'AuthService' });

  async login(email: string, password: string) {
    this.logger.debug('Login attempt:', email);
    
    // ... authentication logic
    
    this.logger.info('User logged in:', email);
  }
}

React Components

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

const logger = new Logger({ namespace: 'useAuth' });

export function useAuth() {
  const login = async (email: string) => {
    logger.debug('Login attempt:', email);
    // ...
  };
  
  return { login };
}

API Client

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

const logger = new Logger({ namespace: 'API', timestamp: true });

async function fetchData(url: string) {
  logger.debug('Fetching:', url);
  
  try {
    const response = await fetch(url);
    logger.info('Response:', response.status);
    return response;
  } catch (error) {
    logger.error('Fetch failed:', error);
    throw error;
  }
}

Migration from console.log

Before:

console.log('🔍 Token found:', token);
console.log('📋 Payload:', payload);

After:

import { debug } from '@tgtone/logger';

debug('Token found:', token);
debug('Payload:', payload);

Production Behavior

With VITE_LOG_LEVELS=error or LOG_LEVELS=error:

  • error() → shown
  • debug(), info(), warn() → suppressed

Development Behavior

With VITE_LOG_LEVELS=* or not defined:

  • ✅ All log levels shown

Changelog

1.2.0

  • ✨ Added timestamp option for ISO timestamp in logs
  • ✨ Added LOG_LEVEL_PRIORITY for level hierarchy
  • 🐛 Fixed child() to properly pass allowedLevels
  • 🐛 Fixed isDebugEnabled() to be consistent with shouldLog()
  • 🔥 Removed deprecated debugEnabled property
  • 🎨 Changed debug emoji from 🔍 to 🐛

1.1.0

  • Initial release with VITE_LOG_LEVELS support

License

MIT

Author

TGT Technology