Nucleic Phosphate Modifier

    ng2-log

    0.1.3 • Public • Published

    ng2-log

    Logger package for Angular2.

    Usage:

    (1) Install the npm module.

    npm i ng2-log --save

    (2) Setup Provider

    ...
    import { log } from 'ng2-log/core';
    @NgModule({
        imports:      [ ... ],
        declarations: [ ... ],
        bootstrap:    [ ... ],
        providers:    [ ...,
                        { provide: log, useValue: log }
                      ]
    });
    

    (3) Import ng2-log

    import { log } from 'ng2-log/core';
    or
    import { log } from 'ng2-log/core';
    or
    import { logger } from 'ng2-log/core';
    

    (4) setting:

       if ('production' === ENV) {
           ...
           log.options.set([]);
    
       } else {
           ...
           log.options.set(['log', 'debug', 'warn', 'error'], ['AppComponent']);
    
       }
    
       // setting usages:
       log.options.set([mothod list], [Module Name List]);
    
       log.options.set([]); or log.options.set([], []); //Turn off all output.
    
       log.options.set(['log', 'debug']); // display the output with methods: 'log' and 'debug'. Posible values: 'error', 'warn', 'info','debug', 'info'
    
       log.options.set('debug', ['CustomerDataService', 'AppComponent']); // display the output with 'debug' method in the specified two modules.
    

    (5) examples:

    log.error(this, 123, [1, 2, 3, 4, 5], { name: 'ng2-log' });
    log.warn(this, 123, [1, 2, 3, 4, 5], { name: 'ng2-log' });
    log.info(this, 123, [1, 2, 3, 4, 5], { name: 'ng2-log' });
    log.debug(this, 123, [1, 2, 3, 4, 5], { name: 'ng2-log' });
    log.log(this, 123, [1, 2, 3, 4, 5], { name: 'ng2-log' });
    log.dir(this, 123, [1, 2, 3, 4, 5], { name: 'ng2-log' });
    

    Note:

    (a) if your import logger,  remember: logger = log.debug
        so you can use:
        logger(this, xx, yy, ...);
    
    (b) Good looking on output a JSON data object, try now.
    

    LICENSE

    MIT

    Contact GitHub

    Install

    npm i ng2-log

    DownloadsWeekly Downloads

    5

    Version

    0.1.3

    License

    MIT

    Last publish

    Collaborators

    • licong-chen