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

@defensive-programming/logger

v0.0.3

Published

A library for shaping your logs.

Downloads

2

Readme

Adze

Adze Logo

build workflow npm Rate this package node-lts size dependency count apache 2.0

Please visit our official docs at adzejs.com.

Why is this named Adze?

A drawing of a man using an adze to shape a log

Photo from Wikipedia

Adze - a cutting tool that ... is used chiefly for shaping wood.

(Pronounced "Ads") Adze was chosen as a name for this library to maintain solidarity with the logging puns and to emphasize that this library is a tool for shaping the logs of your application.

Why should I use Adze?

As you may already be aware there are a number of other good JS libraries out there to assist with logging. The focus of Adze is to provide a convenient and clean API, provide first-class TypeScript support, and to empower you to take command of your logs rather than pigeon-hole you into a specific way of handling them.

Here is a list of the features that Adze provides:

  • First-class TypeScript support
  • Multi-environment support for the Browser and Node
  • Wraps and extends the entire standard API
  • A fluent, chainable API
  • Log Listeners for capturing log data
  • Log annotation namespaces, labels, and other meta data
  • Attractive styling (EMOJI'S INCLUDED and consistent across major browsers)
  • Everything is configurable
  • Enables completely custom log levels
  • A global log store for recalling logs and overriding configuration (supports micro-frontends and modules)
  • Support for Mapped Diagnostic Context
  • Convenient unit testing environment controls
  • Advanced Log Filtering
  • and much more...

Beyond the new features that Adze provides you, it also wraps the entire console web standard. Read more about the standard here: MDN Console Docs

Here is a simple preview:

Preview of Adze logs

This preview was generated from the same code executed in both the browser (left) and the node (right) environments.

What does the API look like?

As stated above, Adze offers an easy to use, chainable API. To create a log you simply chain together an Adze log instance with a series of modifiers and then end with a terminator. Here's an example of creating a log with emoji's and a namespace:

import adze, { createShed } from 'adze';

// Create our global log in-memory cache
const shed = createShed();

// Listen to logs that are generated and operate on them
shed.addListener('*', (data, render, printed) => {
  // if my log printed to the console
  if (printed) {
    // do stuff with my log data like sending to an API or localStorage
  }
});

adze({ useEmoji: true }).ns('tix-456').log('Example log');

The output of this would look like the following:

Preview of Adze logs

Install the Package

You can install Adze from NPM using the following command:

# NPM
npm install --save adze

# Yarn
yarn add adze

Version Requirements

| Dependency | Supported Versions | Notes | | ---------- | ------------------ | ---------------------------------------- | | node | >= 10.x | When running Adze in a Node environment. | | typescript | >= 4.1 | When using Adze with TypeScript |

TypeScript Configuration

Adze is built to be used with TypeScript and we highly encourage using it in this way.

When building your project with TypeScript, you need to make sure you use the "DOM" lib because Adze supports both the web browser and Node. Also, to support the dependencies of Adze, you'll need to add "esModuleInterop": true to your tsconfig as well.

For more information about configuring TypeScript, go to https://www.typescriptlang.org/docs/handbook/tsconfig-json.html.

Example

{
  "compilerOptions": {
    // ...your other options
    "lib": ["DOM"],
    "esModuleInterop": true
  }
}

Importing Adze

Adze comes bundled with a few different ways of accessing it. Here are some examples:

CDN

You can import the library directly into your HTML from the jsDelivr CDN.

NOTE: In the script tag in the example below, replace <version> with the version of Adze you would like to use.

<!-- In the head of your html -->
<head>
  <!-- To use v1.3.0 you would write https://cdn.jsdelivr.net/npm/[email protected]/dist/adze.min.js -->
  <script src="https://cdn.jsdelivr.net/npm/adze@<version>/dist/adze.min.js"></script>
</head>

<!-- Using adze elsewhere in JS -->
<script>
  // Adze is registered globally in your browser as AdzeLib
  const { adze } = AdzeLib;

  adze().log('Hello World!');
</script>

Node JS (CommonJS)

const { adze } = require('adze'); // Or alternatively `const adze = require('adze').adze;`

adze().log('Hello World!');

ES6 / TypeScript

import adze from 'adze';

adze().log('Hello World!');

Documentation

Please visit our official docs at adzejs.com.