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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@valian/function-logger

v0.0.1

Published

A smart logger wrapper for Firebase Functions that automatically switches between production and development logging modes.

Readme

@valian/function-logger

A smart logger wrapper for Firebase Functions that automatically switches between production and development logging modes.

Features

  • 🔄 Automatic Mode Switching: Uses Firebase Functions logger in production and tslog with pretty formatting during development
  • 🎨 Beautiful Console Output: Color-coded logs with timestamps and source file information in development
  • ⚙️ Configurable Log Levels: Control verbosity via environment variables
  • 🔌 Drop-in Replacement: Compatible API with standard logging interfaces

Installation

npm install @valian/function-logger

Or with pnpm:

pnpm add @valian/function-logger

Usage

Basic Usage

import { logger } from '@valian/function-logger'

// Log at different levels
logger.debug('Debugging information')
logger.info('General information')
logger.warn('Warning message')
logger.error('Error occurred', error)

// Log multiple arguments
logger.info('User action:', { userId: '123', action: 'login' })

In Firebase Functions

import { onRequest } from 'firebase-functions/v2/https'
import { logger } from '@valian/function-logger'

export const myFunction = onRequest((request, response) => {
  logger.info('Function invoked', { path: request.path })

  try {
    // Your function logic
    logger.debug('Processing request...')
    response.send('Success')
  } catch (error) {
    logger.error('Function failed', error)
    response.status(500).send('Error')
  }
})

Configuration

Log Levels

Control the minimum log level by setting the LOG_LEVEL environment variable:

# Available levels (in order of verbosity)
LOG_LEVEL=debug  # Shows debug, info, warn, error (default)
LOG_LEVEL=info   # Shows info, warn, error
LOG_LEVEL=warn   # Shows warn, error
LOG_LEVEL=error  # Shows only error

Environment Detection

The logger automatically detects the environment:

  • Development Mode: Uses tslog with pretty formatting when:

    • FUNCTIONS_EMULATOR=true (Firebase Emulator)
    • NODE_ENV=test (Testing environment)
  • Production Mode: Uses Firebase Functions logger when running in deployed functions

API Reference

logger.debug(...args: any[])

Logs debug-level messages. Useful for detailed diagnostic information.

logger.log(...args: any[])

Alias for general logging (same as info).

logger.info(...args: any[])

Logs informational messages about normal application flow.

logger.warn(...args: any[])

Logs warning messages for potentially problematic situations.

logger.error(...args: any[])

Logs error messages for serious problems.

Development

This library is part of the firebase-functions monorepo.

Running Unit Tests

nx test logger

Or using pnpm:

pnpm nx test logger

License

MIT © Valian