Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@getlazy/common

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@getlazy/common

Common utility classes and functions for lazy

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

lazy-common

Common libraries and utilities for lazy

LazyLoggingLevels

Using this object ensures consistent logging levels across all lazy processes running in Node.

Use:

const common = require('@getlazy/common');
const winston = require('winston');

winston.addColors(common.LazyLoggingLevels.colors);
const logger = new winston.Logger({
    // ...
    levels: common.LazyLoggingLevels.levels
});

PackageLogger

External packages cannot know if logger exists on the global level nor what are its levels. This replaces such logging efforts with emitting log events and leaving it to the package's user to listen to these events.

Use:

const common = require('@getlazy/common');
const logger = common.createLogger('my-package'); // We never assign this `logger` to `global` as that would overwrite application's `global.logger`.

// ...

logger.info('Succeeded marvelously.'); // This will emit `log` event. For users to listen to it logger needs to be exported from the package (see next example)

Forwarding log events:

const myPackage = require('my-package');
// This now forwards log events from my-package to Winston.
myPackage.logger.on('log', (level, packageName, ...args) => {
    // In this example we put the package name into meta, if such exists.
    const argsWithoutMeta = [...args];
    const meta = argsWithoutMeta.pop();
    if (typeof(meta) === 'object') { // Nah, not really, use lodash!
        if (!meta._packageName) {
            meta._packageName = packageName;
        }
    }
    logger.log(level, ...messages, meta);
})

Keywords

FAQs

Package last updated on 11 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc