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 🙏

© 2024 – Pkg Stats / Ryan Hefner

taskcluster-lib-log

v10.0.0

Published

A configuration wrapper around Bunyan logging

Downloads

8

Readme

taskcluster-lib-log

A configuration wrapper around Bunyan logging. This module's main purpose is to contain all the taskcluster boiler plate and configuration logic around logging with Bunyan.

We want to use Bunyan logging in our applications so that our logs are easy to parse and obtain insights from. When we use bunyan, we can start putting lots of things in our logs easily and use those to monitor our systems. We can also submit things to security monitoring systems a lot easier if we can combine the logging messages with the security forwarding.

One of the complexities of using bunyan is that it's a very configurable library. Our usage is currently limited to printing to standard output and forwarding that output to a log aggregator.

Log Level Configuration

write this when we finalise the format

Api

The logging object returned by this module is just a bunyan object with a debugCompat property on the root logger. All bunyan APIs after the initial configuration continue to apply. When reading bunyan docs, this library replaced only the bunyan.createLogger call.

Usage

The intention is for each application to only call the function exported by this module once. In a single js-file library, just do that in your code directly. In larger applications, the suggested method is to create a small file (lib/log.js) file which sets up the logging for your whole application. Since require() will cache that module, you'll be sharing the same root logger in all of your code.

This library targets applications which run on systems like Heroku which capture stdio streams and forward them onto a log aggregator.

Right now, we're relying on applications to figure out for themselves how they'd like to figure out what object to pass into logging function. One idea would be to have a file like:

module.exports = require('bunyan-env-config')('my-app', {});

Example code

There is a short example file that demonstrates the minimal amount of code to start logging messages using the supported methods

If you'd like pretty printed output, try running:

node example.js | ./node_modules/.bin/bunyan

Debug Module Compatibility

In order to ease the transition from our usage of the debug module, we have a compatibility interface. This interface requires a configured root logger and is exposed as the debugCompat property on the root logger. We only worry about the part of the API that does log message generation, not the part that deals with controlling output of debug.

Here are the changes required to switch from the old

// First we want to comment out or remove the old debug module
// var debug = require('debug')('my-example:main');

// We need to initialise the logging library
var log = logging("my-example", {});

// We treat the log.debugCompat function as if it were the value
// returned by 'require("debug")'
var debug = log.debugCompat('my-example:main');

// Now our calls to debug() will use bunyan instead
debug('this is a %s of json: %j formatting', 'test', {a: 1});

In the debugCompat module we log messages that contain the string [alert-operator] to the fatal level and all others to the warning level. All messages logged by debugCompat will have structured message properties of dbgcmpt === true and dbgname set to the value that was given to the invocation of og.debugCompat in the preceeding example dbgname would be 'my-example:main'. Messages with [alert-operator] will also have the property alert === true.