ng2-logger
isomorphic logger for browser/server in typescript
Last updated 8 months ago by darekf77 .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install ng2-logger 
SYNC missed versions from official npm registry.

ng2-logger

Isomorphic Logger for TypeScript and JavaScript apps.

You can use this logger in your apps with almost any TS/JS framework.

See what is going on in your app! Now chrome console logs are full of colors!

Modules marked

See nice server logs:

Modules marked

To install package run:

npm install ng2-logger --save

First import proper version for your environment:

Nodejs server:

    import { Log, Level } from 'ng2-logger'

or Browser:

    import { Log, Level } from 'ng2-logger/browser'

Simple use:

In your file with log:

    const log = Log.create('books'); 

or if you wanna just log errors and warnings :

    const log = Log.create('books', Level.ERROR, Level.WARN); 

'books' is current class or anything inside .ts/.js file.

You can also assign static color to specific module in application (browser for now only):

    log.color = 'red'; 

After inited log you are able to start debugging:

    log.d('object',obj) // console.log
    log.er('object',obj) // console.error
    log.i('object',obj) // console.info
    log.w('object',obj) // console.warn

or

    log.debug('object',obj) // console.log
    log.error('object',obj) // console.error
    log.info('object',obj) // console.info
    log.warn('object',obj) // console.warn

Production mode

You will not see anyting in prduction mode:

// enable production mode in your app
...
Log.setProductionMode();
...
// your app code with console and ng2-logger logs

It is important to set production mode before any log messages are executed. This will ensure that log messages that should not be seen are leaked out.

Selective debug - global settings

Optional specify what you wanna see in yours debug console. This settings will override settings from files.

    Log.setProductionMode();
    Log.onlyModules('src:books', 'src:records', 'src:page:login');
    Log.onlyLevel(Level.ERROR,Level.INFO);

Specifying onlyModules as regular expression(s)

In the above example you'll notice module:books and module:records were specified. you might be using such syntax for namespace hierarchy etc. You may also pass in one or more regular expression string(s) to the onlyModule function to specify a selection of modules you wish to show, for instances those whose name begins with src:


    Log.onlyModules( new RegEx('^.src') );

Current Tags

  • 2.0.48                                ...           latest (8 months ago)

68 Versions

  • 2.0.48                                ...           8 months ago
  • 2.0.47                                ...           8 months ago
  • 2.0.46                                ...           a year ago
  • 2.0.45                                ...           a year ago
  • 2.0.44                                ...           a year ago
  • 2.0.43                                ...           a year ago
  • 2.0.42                                ...           a year ago
  • 2.0.41                                ...           a year ago
  • 2.0.40                                ...           a year ago
  • 2.0.39                                ...           a year ago
  • 2.0.38                                ...           a year ago
  • 2.0.37                                ...           a year ago
  • 2.0.36                                ...           a year ago
  • 2.0.35                                ...           2 years ago
  • 2.0.34                                ...           2 years ago
  • 2.0.32                                ...           2 years ago
  • 2.0.31                                ...           2 years ago
  • 2.0.30                                ...           2 years ago
  • 2.0.29                                ...           2 years ago
  • 2.0.26                                ...           2 years ago
  • 2.0.25                                ...           2 years ago
  • 2.0.23                                ...           2 years ago
  • 2.0.21                                ...           2 years ago
  • 2.0.20                                ...           2 years ago
  • 2.0.19                                ...           2 years ago
  • 1.0.12                                ...           2 years ago
  • 1.0.11                                ...           2 years ago
  • 1.0.7                                ...           2 years ago
  • 1.0.6                                ...           2 years ago
  • 1.0.4                                ...           2 years ago
  • 1.0.3                                ...           3 years ago
  • 1.0.2                                ...           3 years ago
  • 1.0.1                                ...           3 years ago
  • 0.2.4                                ...           3 years ago
  • 0.2.3                                ...           3 years ago
  • 0.2.2                                ...           3 years ago
  • 0.1.21                                ...           3 years ago
  • 0.1.20                                ...           3 years ago
  • 0.1.16                                ...           3 years ago
  • 0.1.15                                ...           3 years ago
  • 0.1.14                                ...           3 years ago
  • 0.1.12                                ...           3 years ago
  • 0.1.11                                ...           3 years ago
  • 0.1.10                                ...           3 years ago
  • 0.1.8                                ...           3 years ago
  • 0.1.7                                ...           3 years ago
  • 0.1.5                                ...           3 years ago
  • 0.1.4                                ...           3 years ago
  • 0.1.3                                ...           3 years ago
  • 0.1.2                                ...           3 years ago
  • 0.1.1                                ...           3 years ago
  • 0.0.27                                ...           3 years ago
  • 0.0.26                                ...           3 years ago
  • 0.0.25                                ...           3 years ago
  • 0.0.24                                ...           3 years ago
  • 0.0.22                                ...           3 years ago
  • 0.0.21                                ...           3 years ago
  • 0.0.20                                ...           3 years ago
  • 0.0.18                                ...           3 years ago
  • 0.0.17                                ...           3 years ago
  • 0.0.16                                ...           3 years ago
  • 0.0.15                                ...           3 years ago
  • 0.0.14                                ...           3 years ago
  • 0.0.8                                ...           4 years ago
  • 0.0.7                                ...           4 years ago
  • 0.0.3                                ...           4 years ago
  • 0.0.2                                ...           4 years ago
  • 0.0.1                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 2
This Month 2
Last Day 2
Last Week 0
Last Month 71
Dependencies (5)

Copyright 2014 - 2017 © taobao.org |