Skip to content

How to target angular 2 components instead of node modules ? #33

Open

Description

@cloudscape-germany

To white list, we do:

       Minilog.suggest.defaultResult = false; // Enable Whitelist Mode
        Minilog
            .suggest
            .clear()
            .allow(component,level);
        Minilog.enable();

Would if be possible to target angular2 components to steer the logging on the granular level like with node js modules?

Activity

  1. riddla commented on Nov 14, 2016

    @riddla
    Contributor

    In ES6/Typescript you could make use of the constructor name property:

    export class AppModule {
      constructor() {
        Minilog.suggest.defaultResult = false; // Enable Whitelist Mode
        Minilog
            .suggest
            .clear()
            .allow(this.constructor.name, 'warn');
        Minilog.enable();
    
        let logger = Minilog(this.constructor.name);
    
        logger.debug('will not be displayed');
        logger.info('will not be displayed');
        logger.log('will not be displayed');
        logger.warn('a warning will be displayed');
        logger.error('an error will be displayed');
      }
    }

    I created a running example at http://plnkr.co/edit/4JsuWFFpMFpT4v8eNSHs?p=preview.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions