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

@tent-official/logs-guard

v1.3.0

Published

A utility to suppress console logs in production environment

Readme

@tent-official/logs-guard

A utility to suppress console logs in production environment.

Installation

npm install @tent-official/logs-guard
# or
yarn add @tent-official/logs-guard

Usage

import { logsGuard, logsRelease, logsWarning } from '@tent-official/logs-guard'

// Call at the start of your application (e.g., main.ts)
// This will suppress all specified logs in production
logsGuard()

// To allow a limited number of log lines
logsRelease(1)  // Allow 1 line (default)
logsRelease(3)  // Allow up to 3 lines (max: 5)
logsRelease(0)  // Suppress all logs

// Show styled warning message (Windows only)
logsWarning({
  title: {
    text: 'Warning!',
    style: { color: 'red', fontSize: '20px', fontWeight: 'bold' }
  },
  description: {
    text: 'This is a warning message',
    style: { color: 'orange', fontSize: '14px' }
  }
})

Usage with Express

// src/index.ts
import express from 'express'
import { logsGuard } from '@tent-official/logs-guard'

// Call logsGuard before any other code
logsGuard()

const app = express()

app.get('/', (req, res) => {
  console.log('Request received')  // This will be hidden in production
  res.send('Hello World')
})

app.listen(3000, () => {
  console.log('Server is running')  // This will be hidden in production
})

API

logsGuard(options?)

Guards (suppresses) specified console logs in production environment.

Parameters:

  • options (optional): Configuration object
    • suppress: Array of console methods to suppress. Default: ['log', 'info', 'debug']

Available log methods: 'log' | 'warn' | 'error' | 'info' | 'debug'

logsRelease(lines?)

Allows a limited number of log lines to be displayed before suppressing again.

Parameters:

  • lines (optional): Number of log lines to display. Default: 1, Max: 5, Min: 0

How it works:

  • After calling logsGuard(), all logs are suppressed by default
  • After calling logsRelease(n), the next n log statements will be displayed
  • After reaching the limit, logs will be suppressed again
  • This is useful for debugging in production without showing all logs

Examples:

import { logsGuard, logsRelease } from '@tent-official/logs-guard'

// 1. Initially suppress all logs in production
logsGuard()

console.log('Log 1 - hidden')   // Not displayed
console.log('Log 2 - hidden')   // Not displayed

// 2. Allow 1 line to be displayed
logsRelease(1)

console.log('Log 3 - displayed')   // Displayed (1st line)
console.log('Log 4 - hidden')       // Not displayed (limit reached)

// 3. Allow up to 3 lines (max 5)
logsRelease(3)

console.log('Log 5 - displayed')   // Displayed (1st line)
console.log('Log 6 - displayed')   // Displayed (2nd line)
console.log('Log 7 - displayed')   // Displayed (3rd line)
console.log('Log 8 - hidden')       // Not displayed (limit reached)

// 4. Suppress all logs again
logsRelease(0)

console.log('Log 9 - hidden')       // Not displayed

logsWarning(options)

Displays a styled warning message using console.log with CSS styling. Only works on Windows.

Parameters:

  • options: Configuration object
    • title (required): Text and style for the title
      • text: The text to display
      • style: CSS style object (e.g., { color: 'red', fontSize: '20px' })
    • description (optional): Text and style for the description
      • text: The text to display
      • style: CSS style object

Supported CSS properties: color, fontSize, fontWeight, background, padding, margin, etc.

Note: This function only works on Windows (process.platform === 'win32'). On other platforms, it does nothing.

Examples:

import { logsWarning } from '@tent-official/logs-guard'

// With title only
logsWarning({
  title: {
    text: 'Warning!',
    style: { color: 'red', fontSize: '20px', fontWeight: 'bold' }
  }
})

// With title and description
logsWarning({
  title: {
    text: 'Warning!',
    style: { color: 'red', fontSize: '20px', fontWeight: 'bold' }
  },
  description: {
    text: 'This is a warning message',
    style: { color: 'orange', fontSize: '14px' }
  }
})

Behavior

| Environment | Behavior | |-------------|----------| | Production (NODE_ENV='production') | Suppresses specified logs | | Development (other) | No effect, logs display normally |

Example

import { logsGuard } from '@tent-official/logs-guard'

// Suppress only 'log' and 'info'
logsGuard({ suppress: ['log', 'info'] })

console.log('This will be hidden in production')  // Suppressed
console.info('This will also be hidden')           // Suppressed
console.warn('Warning will still show')           // Shows
console.error('Error will still show')            // Shows

License

MIT