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

meh-logging

v1.4.0

Published

---

Downloads

281

Readme

MEH Logging module


Logging module based on Winston. By default the output will be in JSON format and can be parsed to human readable output when the parser is used.

$ yarn add meh-logging

How to use

import logger from 'meh-logging';

logger.info('Hello world');
logger.debug(['foo', 'bar']); //silenced in production
logger.debug({'foo', 'bar'});  //silenced in production
logger.verbose('verbose message');  //silenced in production
logger.track('kpi');
logger.warn('This should someday be fixed.');
logger.error(new Error('Ow nooo...'));

How to use (express)

The module contains a middleware for express that adds additional metadata to the json output. Fields that are added:

  • requestId
  • path
  • method
  • hostname

Tip: When e.g. an error is thrown, the Request ID can be used to lookup the error within the logging platform.

import logger from 'meh-logging';
import express from 'express';

const app = express();
const port = process.env.PORT || 3000;

app.use(logger.express);

app.get('/', function (req, res) {
  req.logger.info('Received request.');
  res.send('ok');
});

app.listen(port, () => logger.debug(`App listening at http://localhost:${port}`));

Track level

The actions will end up in a kpi reporting platform. For more details see: meh-activity-logger

import logger from 'meh-logging';
// simple
logger.track('action to track');

// advanced
logger.track('action to track', {
  label?: string,
  value?: int,
  priority?: int
});

Human readable output

install the binary

$ yarn global add meh-logging
$ node app.js | meh-printer

Before:

after:

Log levels

ERROR (error): Use when something fatal has happened, that is, something will have user-visible consequences. This level is always logged. Issues that justify some logging at the ERROR level are good candidates to be reported to a log management platform.

WARNING (warn): Use when something serious and unexpected happened, that is, something that will have user-visible consequences but is likely to be recoverable. This level is always logged. Issues that justify logging at the WARNING level might also be considered for reporting to a log management platformr.

INFORMATIVE (info): Use to note that something interesting happened, that is, when a situation is detected that is likely to have widespread impact, though isn't necessarily an error. This level is always logged to a log management platform.

DEBUG (debug): Use to further note what's happening in the application that could be relevant to investigate and debug unexpected behaviors. Log only what's needed to gather enough information about what's going on with your component. If your debug logs are dominating the log, then you should use verbose logging. These logs won't end up in a log management platform and are silences in production environments.

VERBOSE (verbose): Use for everything else. This level is only logged on debug builds.

TRACK (track): Custom Helper log level that can be use when certain KPI's are met and will end up in a kpi reporting platform . For more information:meh-activity-logger

Source: Google Android logging guidelines

Known issues

  • Kubetail is currently not supported due to the fact that it's not using stdout completely.

TODO's

  • Support for logging in the browser.