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

@blueprod/logger

v0.1.9

Published

Logger

Downloads

1

Readme

blueprod Logger

The simple wrapper for Winston logger, just need to import and provide simple configurations under javascript object.

(Note: winston 3.x is used)

Supported transports:

  • console
  • file
  • database (mongodb)
  • http (soon)

How To Use

Example:

const options = {
  "console": {
    "enabled": true,
    "level": "debug"
  },
  "file": {
    "enabled": true,
    "level": "debug",
    "logAppend": true,
    /* 5MB */
    "maxsize": 5*1000000,
    "json": true,
    "prettyPrint": true,
    "depth": 10,
    "tailable": true,
    "zippedArchive": true,
    "datePattern": "yyyy-MM-dd"
  },
  "database": {
    /* @see: https://github.com/winstonjs/winston-mongodb */
    "enabled": true,
    /* url: mongodb://localhost:27017/blueprod_log */
    /* Will remove color attributes from the log entry message, defaults to false. */
    "decolorize": true,
    "leaveConnectionOpen": false,
  },
};

//const logger = require('@blueprod/logger')('MyLogger', options);
const logger = require('../src/Logger')('MyLogger', options);

logger.debug('your debug log message!');
logger.info('your info log message!');
logger.warn('your warn log message!');
logger.error('your error log message!');

Add Hook

TODO not working yet.

This will help us to capture the logger activities when there is a 'warning', 'error' logs.

const hook = {
  level : 'error',
  cb : function(hookInfo) {/* do something */}
};
logger.addHook(hook);

Returned hookInfo will contained propertyName connector(file, console, mongodb), level, message, meta.

Multiple Log Instances

You can use Logger with multiple instances, for each component just create a new instance of Logger with the input parameter is component name. For examples:

const userLogger = require('@blueprod/logger')({name : 'UserDataService'});
const groupLogger = require('@blueprod/logger')({name : 'GroupDataService'});

userLogger.error("Error message"); // error : [IoTDataService] - Error message
userLogger.warn("Warn message");
userLogger.info("Info message");
userLogger.debug("Debug message");
userLogger.verbose("Verbose message");

groupLogger.error("Error message"); // error : [ThingDataService] - Error message
groupLogger.warn("Warn message");
groupLogger.info("Info message");
groupLogger.debug("Debug message");
groupLogger.verbose("Verbose message");

Debug

Logger is built with support the DEBUG environment variable from debug which provides simple conditional logging.

For examples:

todo....

Roadmap

0.1.x

  • Basic functionalities as transports (console/file/database)
  • Debug
  • Hook

0.2.x

  • http support
  • stream support

0.3.x

  • bucket/s3 support
  • Send mail (i.e. on error)

License

MIT license

Author

Developed & maintained by EMSA TECHNOLOGY COMPANY LTD (contact @ emsa-technology dot com).