Socket
Socket
Sign inDemoInstall

@mmit/logging

Package Overview
Dependencies
0
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mmit/logging

Minimal Logging framework


Version published
Maintainers
1
Weekly downloads
49
decreased by-34.67%

Weekly downloads

Readme

Source

Minimal TS Logging framework

Live-Example | GitHub-Home

Very simple but extendable logger in TypeScript.

For now there are only two loggers define: ConsoleLogger and NoOpLogger but it should be easy to define your own logger

Install

# NPM
npm install @mmit/logging

# YARN
npm add @mmit/logging
    

Usage

The "default LogLevel" is 'INFO'

The most simplest way to get the logger is:

    import { LoggerFactory } from '@mmit/logger';

    const logger = LoggerFactory.getLogger('test.Logger');
    
    // Will not be shown
    logger.debug("Shows message only if debug-level is set!");

    // Will not be shown
    logger.info("Shows message only if info-level is set!");

    // Shows the warning message 
    logger.warn("Shows message only if warn-level is set!");

If you need more control:

    import { LoggerFactory, LogLevel } from '@mmit/logger';

     const logger = LoggerFactory.for('test.Logger')
                .level(LogLevel.DEBUG)
                .get();
    
    // Will be shown
    logger.debug("Shows message only if debug-level is set!");

    // Will be shown
    logger.info("Shows message only if info-level is set!");

    // Will be shown
    logger.warn("Shows message only if warn-level is set!");

If you want to specify your own Log-Channel:

    import { LoggerFactory, LogLevel, Channel } from '@mmit/logger';

    class MyCoolLogChannel implements Channel {
        ...
    }

    const myChannel = new MyCoolLogChannel();
    
    const logger = LoggerFactory.for('test.Logger')
                .on(myChannel)
                .level(LogLevel.DEBUG)
                .get();
    
    logger.debug("Shows message only if debug-level is set!");

Keywords

FAQs

Last updated on 31 May 2019

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc