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

@webinmove/gazeti

v1.0.3

Published

A basic Logger object that force a logging format for a correct logstash extraction

Downloads

990

Readme

Gazeti

Description

Gazeti means "log" in Swahili.

A basic Logger object that force a logging format for a correct logstash extraction

Environment Variables

LOG_LEVEL # (optional) Defines you log level, defaut 'info'
LOG_STACK_LEVEL # (optional) Defines minimum level to log stack, default 'error'
LOG_PRETTY # (optional) Defines pretty print output, default false
LOG_LABELS # (optional) Defines if log labels should be used instead of levels, default false
LOG_ERROR_MESSAGE_LENGTH # (optional) Defines error message max length output, default 0 (no limit)
BUILD_NUMBER # (optional) Can be used if we do not use the version.json (see below)

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

const log = require('@webinmove/gazeti')
  .create({ module: module.id });

log.debug('event', {
  user: {
    id : 132
  }
}, {
  user: {
    name: 'Someone'
  }
},
'TRACE-ID-XXXXXXX');

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, traceId);
log.info(event, indexed, raw, traceId);
log.warn(event, indexed, raw, traceId);
log.error(event, indexed, raw, traceId);
log.fatal(event, indexed, raw, traceId);

Output

With this code and a version.json file present:

log.error('ERROR_EVENT', { error: new Error('Some error') }, { foo: 'bar' }, 'TRACE-ID-XXXXXXX');
{
  "level": 50,
  "time": "2019-01-01T00: 00: 00.000Z",
  "hostname": "my-hostname",
  "pid": 71202,
  "version": "1.0.1",
  "projectName": "gazeti",
  "buildNumber": "120",
  "commit": "a8f571799deb70dae2da3ba1de62097700bde304",
  "name": "my-service",
  "module": "mymodule",
  "event": "ERROR_EVENT",
  "indexed": {
    "error": {
      "type": "Error",
      "message": "Some error",
      "stack": "Error: Some error\n    at Context.it (/var/www/gazeti/test/libs/Gazeti.spec.js:191:31)\n    at callFnAsync (/var/www/gazeti/node_modules/mocha/lib/runnable.js:400:21)\n    at Test.Runnable.run (/var/www/gazeti/node_modules/mocha/lib/runnable.js:342:7)\n    at Runner.runTest (/var/www/gazeti/node_modules/mocha/lib/runner.js:455:10)\n    at /var/www/gazeti/node_modules/mocha/lib/runner.js:573:12\n    at next (/var/www/gazeti/node_modules/mocha/lib/runner.js:369:14)\n    at /var/www/gazeti/node_modules/mocha/lib/runner.js:379:7\n    at next (/var/www/gazeti/node_modules/mocha/lib/runner.js:303:14)\n    at Immediate._onImmediate (/var/www/gazeti/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"
  },
  "traceId": "TRACE-ID-XXXXXXX",
  "v":1
}