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

ci-logger

v6.0.0

Published

Very simple logger for CI environments.

Downloads

52,424

Readme

CI Logger

CI Logger is a very simple logger designed for CI environments - no colors, no timestamps - just data. Log entries can be formatted to indicate the results of a previous message, and the process can be terminated of an error is logged.

Usage

const { log, Levels } = require('ci-logger');

log({ message: 'Retrieving data from somewhere...' });
// Retrieving data from somewhere...

log({
  message: 'Error retrieving data',
  isResult: true,
  level: 'warn'
});
//  ⮡ Error retrieving data

log({
  message: 'Error retrieving data',
  isResult: true,
  level: Levels.Error,
  exitOnError: true,
  errorCode: 2
});
//  ⮡ Error retrieving data
// Fatal error - exiting (2)

The log function must be passed an object with the following possible properties:

  • The message property contains the message to be logged and is the only required property. It can be any value except undefined or null.
  • The level property must be one of the strings info, warn, or error (which are the values of the Levels enumeration exposed by the module - Levels.Info, Levels.Warn, Levels.Error). The default value is info (Levels.Info).
  • The isResult property is a boolean value intended to indicate the result of an operation, primarily intended to simplify reading busy CI console logs. If isResult is true, the logged message is indented and prefixed with the resultPrefix string value to indicate it is the result of the preceeding message. If false, the message is not altered. The default value of isResult is false. The default value for resultPrefix is '\u2BA1' ('⮡ ').
  • The exitOnError property is a boolean value indicating whether the process should exit if an error is logged. If true, the error will be logged, a fatal error message will be logged, and process.exit will be called with the errorCode value (an integer). The default value of exitOnError is true, and the default value of errorCode is 1.

The getLogEntry function can be used to retrieve a complete log entry as it would be logged, with default values populating any unspecified values.

const { getLogEntry } = require('ci-logger');
const logEntry = getLogEntry({
  message: 'Retrieving data from somewhere...'
});
// logEntry = {
//     message: 'Retrieving data from somewhere...',
//     isResult: false,
//     level: 'info',
//     exitOnError: true,
//     errorCode: 1,
//     resultPrefix: '\u2BA1'
// }

Default Log Entry Values

The default values for errorCode, exitOnError, isResult, level, and resultPrefix, as detailed above, are used when they are not specified for a specific log entry. If desired, those defaults can be changed using the setLogEntryDefaults function. This function accepts an object with any or all of these values.

const { setLogEntryDefaults, Levels } = require('ci-logger');
setLogEntryDefaults({ errorCode: 2, level: Levels.Warn });

The default values can be set back to the original values via the resetLogEntryDefaults function.

const { resetLogEntryDefaults } = require('ci-logger');
resetLogEntryDefaults();