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

@ucd-lib/logger

v0.0.7

Published

Simple JSON logger based on a combo of Bunyan and GC Logging [LogEntry spec](https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry)

Readme

logger

Simple JSON logger based on a combo of Bunyan and GC Logging LogEntry spec

Contents:

Usage

const {createLogger} = require('@ucd-lib/logger');
const logger = createLogger({
  name : 'my-logger'
});

logger.info('Hello World');

Options

| Option | Env Var | Default Value | |----------|----------|----------| | name | LOG_NAME | ucdlib-logger | | level | LOG_LEVEL | info | | hostname | LOG_HOSTNAME | os.hostname() | | labelsKey | LOG_LABELS_KEY | logging.googleapis.com/labels | | labelsProperties | LOG_LABELS_PROPERTIES | name, hostname, corkTraceId | | errorKeys | LOG_ERROR_KEYS | e, err, error | | timeProperty | LOG_TIME_PROPERTY | time | | noInitMsg | LOG_NO_INIT_MSG | false |

  • name: The name of the logger. This will be the name of the log stream in the JSON output.
  • level : The log level. One of trace, debug, info, warn, error, fatal. All calls to the logger will be logged at this level or higher.
  • hostname : The hostname of the machine running the logger.
  • labelsKey : The key to use for labels in the JSON output. Set to false to disable labels and all label properties will stay in the root of the JSON output. Default is logging.googleapis.com/labels which is the key used by Google Cloud Logging.
  • labelsProperties : A comma separated list of properties to include in the labels object.
  • errorKeys : A comma separated list of keys to look for in the log message objects for an an Error object. If an error object is found, it will be serialized and added to the log message.
  • timeProperty : The property to use for the time in the log message. Default is time.

How it works.

You can log as many arguments as you want. Each argument should be a string or an object. All objects passed will be merged into a single object. All strings will be concatenated into a single string sperated by a ; and set as the message property of the log object. The following properties will be added to the log object:

  • message : The string representation of all string arguments passed to the logger.
  • name : The name of the logger.
  • hostname : The hostname of the machine running the logger.
  • time : The current time in ISO format.
  • severity : The log level. Based on the logger function called.
  • httpRequest : Only if the req and res objects are passed (see more below).

Additionally labelsProperties will be moved to the labelsKey property if set.

Logging Requests

There is built in middleware for logging requests.

Example:

import express from 'express';
import {logReqMiddleware, createLogger} from '@ucd-lib/logger';

const app = express();
const logger = createLogger({
  name : 'my-logger'
});

app.use(logReqMiddleware(logger));

app.get('/', (req, res) => {
  res.send('Hello World');
});

app.listen(3000, () => {
  logger.info('Server running on port 3000');
});

This middleware will:

  • Format the req and res objects as the LogEntry HttpRequest object.
  • Timing information will be added to the log message, added to the latency property of the httpRequest object.
  • The log message will be logged at the INFO level unless the response status code is 5xx, in which case it will be logged at the ERROR level.
  • Check for the corkTraceId property on the req object or cork-trace-id in the headers. If found, add it to the log message as a label. If the corkTraceId property is not found, a new corkTraceId will be generated and added to the req object, cork-trace-id added to the req.header (for use by a later proxy), added to the log message as a label.

Alternatively, you could, though not receommended, log the request manually:

logger.info({req, res, reqTimeInMs});

Options: | Option | Env Var | Default Value | |----------|----------|----------| | [not available ] | LOG_REQ | true | | ignore | LOG_REQ_IGNORE | null | | debug | LOG_REQ_DEBUG | null |

  • LOG_REQ : Env var only. Set to false to disable request logging. Default is true. This is usefule for environments such as Google Cloud Run where the request logs are already captured.
  • ignore : Array of RegExp objects or a single string with comma separated regular expressions. If the request path matches any of the RegExps, the request will not be logged.
  • debug : Array of RegExp objects or a single string with comma separated regular expressions. If the request path matches any of the RegExps, the request will be logged at the DEBUG level.