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

@pillarwallet/common-logger

v1.2.101

Published

A common module that allows a logger to be instantiated and returns an instance of a logger.

Downloads

10

Readme

common-logger

Common-logger is a utility that takes a set of configuration parameters and returns a logger.

Common-logger currently supports two log types: Console(stdout), File(stream).

Updating this README.md

Run npm run generateReadme to parse the code for JSDoc comment blocks and recreate this README.md file.

Install

Run npm i @pillarwallet/common-logger

Examples

Instantiate a logger with default options (just writing out to Console): @param level - (optional) set the level for a single output stream @param name - (required) name of Log @param path - (optional) Specify the file path to which log records are written @param src - (optional - default false). Set true to enable 'src' automatic field with log call source info

const buildLogger = require('@pillarwallet/common-logger');

const logger = buildLogger({ level: 'info', name: 'logTest', path: __dirname , src: false });
logger.info('Logger Info Hey!');
logger.warn('Logger Warn Hey!');
logger.fatal('Logger Fatal Hey!');
logger.error('Logger Error Hey!');
// with serializer
// "serializer" functions to produce a JSON-able object from a JavaScript object, so you can easily do the following:
const req = {
  method: req.method,
  url: req.url,
  headers: req.headers
};
logger.info(req, 'Logger Info Test!');

To use HTTP request logger middleware, just follow the example:

const express = require('express');

const app = express();

app.use(logger.middleware());

Standard serializers are:

|Field |Description| | ----- | --------------------------------------------------------------------------------------- | | err | Used for serializing JavaScript error objects, including traversing an error's cause chain for error objects with a .cause() -- e.g. as from verror.| | req | Common fields from a node.js HTTP request object.| | res | Common fields from a node.js HTTP response object.|

API

Members

Functions

Constructor ⇒

This is the constructor of the Logger instance. It allows to set Configuration keys:

Kind: global variable
Returns: Object

| Param | Type | Description | | --- | --- | --- | | name | String | (required) name of Log | | level | String | (optional) set the level for a single output stream | | path | String | (optional) Specify the file path to which log records are written | | src | Boolean | (optional) Defaults to false. Set true to enable 'src' automatic field with log call source info |

middleware

use this method as middleware to log http requests.

Kind: global variable

| Param | | --- | | req | | res | | next |

httpHeaderParser(string, begin, end) ⇒ string

Simple string parser

Kind: global function

| Param | | --- | | string | | begin | | end |