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

@cornerstone-digital/loggerhead

v1.4.8

Published

Logging library with PCI compliance masking functionality built in.

Downloads

309

Readme

loggerhead

Logging library with PCI compliance masking functionality built in.

Often when dealing with

Installation

yarn add @cornerstone-digital/loggerhead

How it works

Loggerhead is a wrapper around the npm module debug which adds support for enabling/disabling logging at certain levels based on the configuration.

The logger also has support for masking data within log files using either one of the default rules (see below) or using custom rules which can be configured within your configuration given on inititialisation of the logger.

Installation

To install with yarn run:

yarn add @cornerstone-digital/loggerhead

To install with npm run:

npm -i @cornerstone-digital/loggerhead

Supported Log Levels

OFF: 0 or LogLevels.OFF
FATAL: 1 or LogLevels.FATAL
ERROR: 2 or LogLevels.ERROR
WARN: 3 or LogLevels.WARN
INFO: 4 or LogLevels.INFO
DEBUG: 5 or LogLevels.DEBUG
TRACE: 6 or LogLevels.TRACE
ALL: 7 or LogLevels.ALL

Usage

To initialise a logger instance you can use the below code:

import Loggerhead, { LoggerheadConfig, LogLevels } from '@cornerstone-digital/loggerhead'

const loggerConfig: LoggerheadConfig = {
  namespace: 'MyLogger',
  enabled: true,
  level: LogLevels.ALL,
  timeStamp: true,
  timeStampFormat: 'YYYY-MM-DD HH:mm:ss',
  logFile: {
    enabled: true /* Enable logging to file */,
    fileName: 'debug.log' /* Filename to use */,
    options: {
      path: `${process.cwd()}/.logs` /* Log file location */,
      compress: true /* Enable compression */,
      size: '10M' /* Max file size before rotation */,
      maxFiles: 5 /* Max number of files to keep */
    }
  },
  masking: {
    enabled: true,
    enableDefaults: {
      email: true /* Enable masking emails */,
      phone: true /* Enable masking phones */,
      postcode: true /* Enable masking postcodes */,
      password: true /* Enable masking passwords */,
      jwt: true /* Enable masking jwt tokens */
    },
    rules: [
      /* Exactly match a key based on it's name matching the matchValue */
      {
        name: 'id',
        type: 'Key',
        matchValue: 'myKeyName',
        replaceWith: '*********'
      },
      /* Match a key based on if it's name contains the matchValue */
      {
        name: 'id',
        type: 'KeyIncludes',
        matchValue: 'id',
        replaceWith: '*********'
      },
      /* Match a strings in a log based on RegExp */
      {
        name: 'myRegExpMatch',
        type: 'RegEx',
        matchValue: new RegExp(/\b(.*)\b/gi),
        replaceWith: '*********'
      }
    ]
  }
}

logger.info('My log')