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

@xazure/logger

v0.1.0

Published

An extensible, configurable logger.

Readme

Xazure Logger

An extensible, configurable logger. Used by Xazure CMS.

Provides a singleton which can easily be used in any module in your project.

Basic Usage

import logger from 'xazure-logger';
import consoleLogger from 'xazure-logger-module-console';

logger.configure({ modules: [consoleLogger] });
logger.log('Hello World');

Modules

Xazure Logger does no logging without a logging module. By adding modules, you can log to anything, whether it is the browser console, a file system, an HTTP endpoint, or anything else.

A module is quick simple. It's just a function that accepts the config object and returns a method with logging.

export default config => (level, messages) => {
  // do something with messages
}

You don't have to check the level against the configuration, logger will do that itself and only call the plugin method when it should do the logging.

The config it is given is the same one given to logger. Anytime the logger configuration is changed, all modules will be regenerated with the new configuration as well.

By convention, logging modules for Xazure Logger should be xazure-logger-module-*.

Logging Levels

The logger has 5 different built-in levels, in order: ERROR, WARN, INFO, LOG, DEBUG. There are constants available on the Levels object.

import logger, { Levels } from 'xazure-logger';

The logger has a logging level which controls which messages are given. Setting the logger to a level will log all messages of that level and higher. For example, if you set it to INFO, you'll log ERROR, WARN, and INFO messages, while LOG and DEBUG will be ignored.

You can change the level with logger.configure().

import logger, { Levels } from 'xazure-logger';

logger.configure({ level: Levels.INFO });

There are functions for each level: error(), warn(), info(), log(), debug(). You can give it any number of messages:

`error('A', 'B', 'C', 'D')`

You can also log with a number:

`logAt(41, 'A')` 

This can allow you to specify your own custom levels.

It's recommended that you set the level with a configuration file or environment variables, so you can have more verbose levels while developing, and less verbose in production.

Singleton vs. Instances

import logger, { Logger } from 'xazure-logger';

const newLogger = Logger();

logger is a singleton. It'll always have the same configuration in all files. In most cases, this is what you'll want to use.

Logger() will create a non-singleton instance which can have a separate configuration from the singleton. Note: If you want to share this around, you'll have to pass it manually.

Configuration

 // Defaults
 {
   modules: []
   level: Levels.VERBOSE
 }
 

You can configure an existing instance, like the singleton, with configure():

logger.configure(newConfig);

Note: When you call logger.configure, it will merge the values into the existing configuration (only changing what you provided). If you want to restore it to the defaults, you can use getDefaultConfig().

You can also pass a configuration when creating a new instance:

const newLogger = Logger(config);

API

logger

import logger from 'xazure-logger';

A singleton instance of Logger() for easily using the logger anywhere with shared configuration.

Logger(config)

import { Logger } from 'xazure-logger';
    

Creates a new instance of Logger with the given configuration object. See Configuration for properties. config is optional.

Levels.ERROR
Levels.WARN
Levels.INFO
Levels.LOG
Levels.DEBUG

import { Levels } from 'xazure-logger';

The default logging levels, in order of verbosity.

getDefaultConfig();

import { getDefaultConfig } from 'xazure-logger';

Gets the default config object.

logger.error(...messages)  // Levels.ERROR
logger.warn(...messages)   // Levels.WARN
logger.info(...messages)   // Levels.INFO
logger.log(...messages)    // Levels.LOG
logger.debug(...messages)  // Levels.DEBUG

Logs at the corresponding logging level.

logger.logAt(level:number, ...messages)

Logs messages at the provided level.

logger.willLog(level):boolean

Indicates if the given level would log.