minilog icon indicating copy to clipboard operation
minilog copied to clipboard

How to target angular 2 components instead of node modules ?

Open cloudscape-germany opened this issue 9 years ago • 1 comments

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?

cloudscape-germany avatar Sep 13 '16 11:09 cloudscape-germany

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.

riddla avatar Nov 14 '16 12:11 riddla