Coder Social home page Coder Social logo

ember-debug-logger's Introduction

ember-debug-logger Build Status

ember-debug-logger exposes the visionmedia/debug library for use in your Ember.js application.

Installation

ember install ember-debug-logger

Usage

Enabling Namespaces During Debugging

During development, you can enable logging for particular namespaces calling debug.enable in the developer console. Your preferences will be persisted in local storage, but they're only checked when a logger is instantiated, so in most cases you'll need to refresh the page to see them take effect.

Enabled namespaces follow simple globbing rules, so to enable logging for everything, you could use:

debug.enable('*');

To enable only logging coming from the application route:

debug.enable('route:application');

You can mix and match as well. To enable logging for all routes and the foo-bar service, for instance:

debug.enable('route:*, service:foo-bar');

You can turn off all logging with disable:

debug.disable();

Namespaces will automatically be differentiated by color, and the time between messages will be logged.

image

Automatic Namespacing

By default, this addon will inject a debug method on to all routes, components, controllers, and services that are instantiated by your application's container. This method will automatically use its instance's container key as the namespace.

// index/route.js
import Ember from 'ember';

export default Ember.Route.extend({
  activate() {
    this.debug('Hello from the application index.');
  }
});

image

You can also manually add the method when defining any other class that will be instantiated by the container.

import Ember from 'ember';
import DS from 'ember-data';
import debugLogger from 'ember-debug-logger';

export default DS.RESTAdapter.extend({
  debug: debugLogger(),
  
  _sayHi: Ember.on('init', function() {
    this.debug('Hello from the application adapter!');
  })
});

image

Manual Namespacing

If you want to log debug messages from anywhere other than a container-managed object, you can manually specify a namespace in the same way you would with the underlying debug library.

import debugLogger from 'ember-debug-logger';
const debug = debugLogger('demo-namespace');

debug('Hello, world');

image

ember-debug-logger's People

Contributors

dfreeman avatar ember-tomster avatar ramblurr avatar

Watchers

 avatar  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.