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

saga-logger

v4.0.7

Published

A basic Logger object that force a logging format, can use logentries

Downloads

2,472

Readme

Sagacify Standarized Logger

npm version ci semantic-release

Environment Variables

LOG_LEVEL # (optional) Defines you log level, defaut 'info'
LOG_ENDPOINT # (optional) Defines an udp endpoint format: 10.0.10.100:5300
LOG_STACK_LEVEL # (optional) Defines minimum level to log stack, default 'error'
LOG_PRETTY # (optional) Defines pretty print output, default false
LOG_ERROR_MESSAGE_LENGTH # (optional) Defines error message max length output, default 0 (no limit)

Notes:

  • LOG_ENDPOINT is intended to be used with AWS Lambda and will be over UDP
  • LOG_PRETTY is intended to be used in local development
  • LOG_ERROR_MESSAGE_LENGTH is intended to be used when package like request log full request content with files...

Automatic loads

This logger automatically loads info from the package.json but also from a version.json file if present at the root of the project.

version.json structure

{
  "projectName": "my-project",
  "buildNumber": "120",
  "commit": "a8f571799deb70dae2da3ba1de62097700bde304"
}

Usage

import { logger } from 'saga-logger';
// Or
const { logger } = require('saga-logger');

const log = logger.create({ module: 'files-controller' });

log.info('event', {
  user: {
    id : 132
  }
}, {
  user: {
    name: 'Someone'
  }
});

The indexed and raw parameters are optional. They can be or they can contain an Error object in a error field which will be serialized

Here are the different logging methods:

log.debug(event, indexed, raw);
log.info(event, indexed, raw);
log.warn(event, indexed, raw);
log.error(event, indexed, raw);
log.fatal(event, indexed, raw);

Output

With this code and a version.json file present:

log.error('ERROR_EVENT', { error: new Error('Some error') }, { foo: 'bar' });
{
  "level": 50,
  "time": "2019-01-01T00: 00: 00.000Z",
  "hostname": "my-hostname",
  "pid": 71202,
  "version": "1.0.1",
  "projectName": "logger",
  "buildNumber": "120",
  "commit": "a8f571799deb70dae2da3ba1de62097700bde304",
  "name": "saga-logger",
  "module": "mymodule",
  "event": "ERROR_EVENT",
  "indexed": {
    "error": {
      "type": "Error",
      "message": "Some error",
      "stack": "Error: Some error\n    at Context.it (/var/www/logger/test/libs/Logger.spec.js:191:31)\n    at callFnAsync (/var/www/logger/node_modules/mocha/lib/runnable.js:400:21)\n    at Test.Runnable.run (/var/www/logger/node_modules/mocha/lib/runnable.js:342:7)\n    at Runner.runTest (/var/www/logger/node_modules/mocha/lib/runner.js:455:10)\n    at /var/www/logger/node_modules/mocha/lib/runner.js:573:12\n    at next (/var/www/logger/node_modules/mocha/lib/runner.js:369:14)\n    at /var/www/logger/node_modules/mocha/lib/runner.js:379:7\n    at next (/var/www/logger/node_modules/mocha/lib/runner.js:303:14)\n    at Immediate._onImmediate (/var/www/logger/node_modules/mocha/lib/runner.js:347:5)\n    at runCallback (timers.js:694:18)\n    at tryOnImmediate (timers.js:665:5)\n    at processImmediate (timers.js:647:5)"
    }
  },
  "raw": {
    "foo": "bar"
  },
  "v":1
}