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

@naturacosmeticos/clio-nodejs-logger

v3.0.0

Published

[![Known Vulnerabilities](https://snyk.io/test/github/natura-cosmeticos/clio-nodejs-logger/badge.svg?targetFile=package.json)](https://snyk.io/test/github/natura-cosmeticos/clio-nodejs-logger?targetFile=package.json) [![Build Status](https://travis-ci.org

Downloads

70

Readme

Known Vulnerabilities Build Status Codacy Badge

Clio Node.js Logger

What For

This module offers a logger with context per request. So it's supporting correlation id, session id, etc in any point of your application. You just need create a domain and Logger.current.

How to use

Install the package on your project using either npm or yarn:

npm i '@naturacosmeticos/clio-nodejs-logger'

yarn add '@naturacosmeticos/clio-nodejs-logger'

Example:

const domain = require('domain');
const Logger = require('@naturacosmeticos/clio-nodejs-logger');

const currentDomain = domain.create();
const context = { correlationId: '39c74d4d-50a9-4ccb-8c7d-ac413564f4a1' };

currentDomain.logger = new Logger({ context, logPatterns: '*' });

function myAwesomeAppEntryPoint() {
  Logger.current().log('Awesome app running with execution context!');

  new Logger({ logPatterns: '*' }).log('Awesome app running without execution context!');
}

currentDomain.run(myAwesomeAppEntryPoint);

By default all log namespaces are disabled. To enable them you must pass the LOG_NAMESPACES environment variable with the logging patterns you want to show.

If you need to filter your logs by level you can either use LOG_LEVEL environment variable or pass the option into its contructor when instantiating new Logger({ ...options, logLevel: 'info' }).

This variable follows the same semantics as the debug library on npm.

By default the log object will be truncated* when it exceed 7kb and the log level is not debug. If you need to increase this limit, you can set environment variable LOG_LIMIT with the value in bytes (i.e.: 10000 = 10kb) or pass the limit in the Logger constructor: new Logger({ ...options, logLimit: 10000 });

* when the log object is truncated only the following attributes are logged: context, level, message and timestamp.

Available options and details of how use this lib can be found in the docs, that can be generated running npm run docs or yarn docs.

Features

Clio has the basic features of a logger library:

  • log levels: you can use debug, error, log and warn levels
  • namespaces: with namespaces you can control which namespaces should be logged using the same semantics as the debug

Beyond those common log features Clio has additional features:

  • Context per request: you can use domain and then Logger.current to use the same logger instance inside in your application. So we can have the same context and additional information in your log as: correlationId and sessionId (see an example in execution-context)
  • Limit your log event size: when the log level is not debug the log object will have size limit of 7kb (you can increase passing a new limit in the logger constructor). This limit exists to avoid problems during log parsing and avoid usage of unnecessary resources (i.e.: when developer forgets log call during debugging).

Docs

Check out Wiki

Samples

Take a loot at the samples folder for examples of usage.

How to contribute

You can contribute submitting pull requests.

Setup

Run yarn.

Testing

Just run yarn test.

Lint

To verify if any lint rule was broken run: yarn lint.