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

@untools/logger

v0.0.8

Published

An enhanced logger for JavaScript/TypeScript that handles DOM elements and circular references

Downloads

678

Readme

@untools/logger

A powerful and flexible logging utility for JavaScript and TypeScript applications that handles complex data types including DOM elements and circular references. Built to work seamlessly across all environments including Next.js (client, server, and edge runtimes).

Features

  • Universal compatibility: Works in browsers, Node.js, and edge runtimes (including Next.js middleware)
  • Handles DOM elements, circular references, and complex objects
  • Color-coded console output
  • Stack trace info for each log
  • Configurable logging levels
  • Timestamp support
  • Grouping and timing functionality
  • Isomorphic design - use the same logger code everywhere

Installation

npm install @untools/logger

Basic Usage

import { logger } from '@untools/logger';

// Basic logging
logger.info('Server started on port 3000');
logger.warn('Deprecated function called');
logger.error(new Error('Something went wrong'));
logger.debug({ user: { id: 1, name: 'John' } });

// Logging DOM elements (browser only)
logger.info(document.getElementById('app'));

// Handling circular references
const circular = { name: 'circular object' };
circular.self = circular;
logger.info(circular);

Next.js Usage

The logger works in all Next.js environments:

// In server components, API routes, middleware or client components
import { logger } from '@untools/logger';

// Server-side usage
export async function getServerSideProps() {
  logger.info('Fetching data on server');
  // ...
}

// Middleware usage
export default async function middleware(req) {
  logger.info('Processing request in middleware');
  // ...
}

// Client-side usage
useEffect(() => {
  logger.info('Component mounted', { componentState });
}, []);

Custom Logger Configuration

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

const customLogger = new Logger({
  showInProd: true,
  includeTimestamp: true,
  maxDepth: 3,
  maxStringLength: 5000,
  enableCircularHandling: true,
  domElementFormat: 'inspect'
});

customLogger.info('Using custom logger configuration');

API

LoggerOptions

| Option | Type | Default | Description | |--------|------|---------|-------------| | showInProd | boolean | false | Show logs in production environments | | includeTimestamp | boolean | true | Include ISO timestamps in logs | | maxDepth | number | 5 | Maximum recursion depth for object formatting | | maxStringLength | number | 10000 | Maximum string length before truncation | | enableCircularHandling | boolean | true | Enable detection and handling of circular references | | domElementFormat | 'inspect' | 'summary' | 'disabled' | 'summary' | Format for DOM elements |

Methods

  • log(...args): General logging
  • debug(...args): Debug level logging
  • info(...args): Information level logging
  • warn(...args): Warning level logging
  • error(...args): Error level logging
  • group(label): Start a collapsible group in console
  • groupEnd(): End the current group
  • time(label): Start a timer
  • timeEnd(label): End timer and log elapsed time

Environment Detection

The logger automatically detects the runtime environment and adjusts its behavior accordingly:

  • Browser: Full color support and DOM element inspection
  • Node.js: Terminal color support with ANSI codes
  • Edge Runtime: Simplified output suitable for edge environments

License

MIT