Code Monkey home page Code Monkey logo

ng2-logger's Introduction

ng2-logger

Logger for TypeScript and JavaScript apps.

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

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

Modules marked

To install package run:

npm install ng2-logger --save

First import it:

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

Simple use:

Init your 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 file.

You can also assign static color to specific module in application:

    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

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('^src');

ng2-logger's People

Contributors

abrahamrkj avatar darekf77 avatar gerritk avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.