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

meilog

v1.0.0

Published

📃 beautiful logging library with support for structured logs (for cloud services) and local logging with colors

Downloads

5

Readme

:page_with_curl: meilog

beautiful logging library with support for structured logs (for cloud services) and local logging with colors

meilog yarn demo screenshot

Motivation

This library aims to provide a simple logging solution based on winston.

Who is this for? If you do not want to spend a lot of time setting up your logging library, and want it to work with cloud platforms while still having your looks look neat in your local development environment.

How does it work? The library exports a createLogger function, which can be used to create a logger for a given application. Then, each part of the application (called service) can have its own logging namespace. We also provide convenient logging functions for debug, info, warn, error and crit logs, which are all compatible with the winston logging functions. Additionally, we provide an exception function to easily log exceptions.

Structured logs? Cloud Services? When the library is used in a production environment, it will default to printing the logs in structured JSON format, so that cloud platforms can parse the logs, for example:

{"message":"hello world!","severity":"info","app":"logger","component":"log"}

Installation

First install the library with npm:

npm install --save meilog

Or with yarn:

yarn add meilog

Usage

This library can be used with both ES6 imports or the default node.js import system using require.

ES6 imports

It is recommended that you create a new log.js file in your project:

import createLogger from 'meilog'

const makeLogger = service => createLogger('APPNAME', service)

export default makeLogger

Then, use the logger as follows:

import makeLogger from './log'
const { debug, info, warn, error, crit, exception } = makeLogger('SERVICENAME')

debug('Debug or trace information.')
info('Routine information, such as ongoing status or performance.')
warn('Warning events might cause problems.')
error('Error events are likely to cause problems.')
exception(new Error('something went wrong!'))
crit('Critical events cause more severe problems or outages.')
exception(new Error('fatal error'), 'crit')

node.js imports

It is recommended that you create a new log.js file in your project:

const createLogger = require('meilog')

module.exports = service => createLogger('APPNAME', service)

Then, use the logger as follows:

const { debug, info, warn, error, crit, exception } = require('./log')('SERVICENAME')

debug('Debug or trace information.')
info('Routine information, such as ongoing status or performance.')
warn('Warning events might cause problems.')
error('Error events are likely to cause problems.')
exception(new Error('something went wrong!'))
crit('Critical events cause more severe problems or outages.')
exception(new Error('fatal error'), 'crit')

Log levels

We use a subset of the official syslog log levels:

  • crit: Critical events cause more severe problems or outages.
  • error: Error events are likely to cause problems.
  • warn: Warning events might cause problems.
  • info: Routine information, such as ongoing status or performance.
  • debug: Debug or trace information.

Configuration

The logging library is configured using the following environment variables:

  • LOG_LEVEL (default: info) - everything higher than this level is logged
  • LOG_DISABLE_JSON (default: false) - disable structured JSON logs in production
  • NODE_ENV (default: development) - set to production to enable structured JSON logs or simpler logs (without colors)