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

@mpaauw/yinston

v0.1.1

Published

A light, easy-to-use, production-ready wrapper for Winston.

Downloads

13

Readme

Build npm version License: MIT

yinston

A light, easy-to-use, production-ready wrapper for Winston.

Installation

To get started, simply install via npm:

npm install @mpaauw/yinston

Usage

To use Yinston for logging, first instantiate your logger, passing in an optional filename to be used by the logger itself:

Instantiation

import { Logger } from '@mpaauw/yinston';
import { YinstonLogger } from '@mpaauw/yinston';

const logger: Logger = YinstonLogger.createLogger(__filename);

Logging Events

Next, you can use your logger as you normally would, passing events with the relevant severity level:

logger.info('Not all those who wander are lost.');

logger.debug('All we have to decide is what to do with the time that is given us.');

logger.error('It’s the job that’s never started as takes longest to finish.');

... which should give you the following logs:

[2022-11-28T20:55:30.039Z] [yourFileNameHere.ts] info: Not all those who wander are lost.

[2022-11-28T20:55:30.039Z] [yourFileNameHere.ts] debug: All we have to decide is what to do with the time that is given us.

[2022-11-28T20:55:30.040Z] [yourFileNameHere.ts] error: Its the job thats never started as takes longest to finish.

Logging Objects

You can also easily pass entire objects to be written to your log event:

logger.debug(`We've had one, yes. What about second breakfast?`, {
    character: {
      name: 'Peregrin Took',
      heightInMeters: 1.38,
      realm: Locations.Shire
    },
    secondBreakfast: {
      isHappening: false
    }
  });

which results in the following log:

[2022-11-28T21:02:03.441Z] [yourFileNameHere.ts] debug: We've had one, yes. What about second breakfast?
{
  character: { name: 'Peregrin Took', heightInMeters: 1.38, realm: 'Shire' },
  secondBreakfast: { isHappening: false }
}

Configuration

It's important to note that by default, Yinston will pretty-print logs (objects included). To disable this and opt for json-only logging (which is recommended for production environments), simply set the following variable in your environment:

NODE_ENV=production

This will instruct Yinston to only print logs to .json format. For example, the object log described above, when NODE_ENV is set to production, would look like this:

{"character":{"heightInMeters":1.38,"name":"Peregrin Took","realm":"Shire"},"level":"debug","message":"We've had one, yes. What about second breakfast?","secondBreakfast":{"isHappening":false},"timestamp":"2022-11-28T21:21:00.933Z"}

Testing

To mute logs when running tests, simply include a --silent within your test script.

For example, if you're running unit tests with Jest, simply add the following test script in your package.json file:

"test": "jest --runInBand --coverage --silent --forceExit --testPathPattern=*",