Skip to content

Conveniently route log messages to nowhere, console, or debug

License

Notifications You must be signed in to change notification settings

jacobq/ember-optional-debug

Repository files navigation

ember-optional-debug

Provides a convenience factory utility for https://github.com/debug-js/debug (formerly maintained by visionmedia) that:

  • Generates log, logVerbose, and warn functions based on a given namespace/scope.
  • Specifies debug as a peerDependency so that the consuming application or addon can specify which version should be used (hopefully preventing version conflicts).

Compatibility

  • Ember.js v3.24 or above
  • Ember CLI v3.24 or above
  • Node.js v12 or above

Installation

ember install ember-optional-debug

Usage

// environment.js
'use strict';

module.exports = function (environment) {
  let ENV = {
    modulePrefix: 'my-thing',
    environment,
    // ...
    'ember-optional-debug': {
      //logProvider: 'none', // log = () => undefined
      //logProvider: 'console', // log = console.log.bind(console)
      logProvider: 'debug', // log = debug(yourNamespace)
    },
    // ...
  };
  // ...
  return ENV;
};
//import { getLoggingFunctions } from `ember-optional-debug`;
import { getLoggingFunctions } from "ember-optional-debug/utils/log";

const { log, logVerbose, warn } = getLoggingFunctions(`my-namespace:foo`);
log('hello'); // [console.log] my-namespace:foo hello
logVerbose('world'); // [console.log] my-namespace:foo:verbose world
warn('boom'); // [console.warn] my-namespace:foo boom

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.

About

Conveniently route log messages to nowhere, console, or debug

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published