New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

lggr

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lggr

```javascript import * as lggr from 'lggr';

  • 2.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

Example

import * as lggr from 'lggr';

var webFile = new lggr.WebFile({
    fileName: 'debug.log',
    oldFileName: 'debug-old.log',
    maxSize: 5 * 1024 * 1024
});

var webFileFormatter = lggr.combineFormatters([
    lggr.createPlaceholdersFormatter(),
    lggr.createPrefixFormatter(prefix => `-[${prefix}]-`),
    lggr.createMethodFormatter(method => method.toUpperCase()),
    lggr.createDateFormatter(),
    lggr.createJoinFormatter(' # ')
]);

var consoleFormatter = lggr.combineFormatters([
    lggr.createNormalFormatter({j: 'o', l: 's'}),
    lggr.createPrefixFormatter(),
    lggr.createJoinFirstFormatter(2, '|')
]);

var options = {
    methods: ['log', 'info', 'warn', 'error'],
    writers: {
        console: lggr.createConsoleWriter(),
        file: lggr.createWebFileWriter(webFile)
    },
    formatters: {
        console: consoleFormatter,
        file: webFileFormatter
    },
    levels: {
        console: ['warn', 'error'],
        file: ['log', 'info', 'warn', 'error']
    }
};

var logger = new lggr.Logger('log-prefix', options);

logger.log('Hello, %s! I am %i years old!', 'world', 142);
logger.error('Hello, %s! I am %i years old!', 'world', 142);
logger.warn('Hello, %s! I am %i years old!', 'world', 142);
logger.info('Hello, %s! I am %i years old!', 'world', 142);

var otherLogger = logger.clone('other-log-prefix');
otherLogger.info('Hi, %o', {world: 'Earth', age: 9999999999})

// this methods are applied to both logger and otherLogger
// (and to any other clones of logger and clones of otherLogger and clones of clones of...)
logger.setLevels('console', ['log'])
logger.addFormatter('file', lggr.createDateFormatter())

// this methods are applied only to otherLogger
otherLogger.setLevels('console', ['error', 'warn'])
otherLogger.addFormatter('file', someOtherFormatterMethod)

var forkedLogger = logger.fork('forked-prefix');

// you can change forkedLogger options only by calling methods of forkedLogger itself
forkedLogger.setLevels('console', ['warn'])

FAQs

Package last updated on 26 Oct 2016

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