├── app └── .gitkeep ├── vendor └── .gitkeep ├── tests ├── helpers │ ├── .gitkeep │ ├── destroy-app.ts │ ├── resolver.js │ ├── start-app.ts │ └── module-for-acceptance.ts ├── unit │ ├── .gitkeep │ └── utils │ │ └── debug-logger-test.ts ├── dummy │ ├── app │ │ ├── helpers │ │ │ └── .gitkeep │ │ ├── models │ │ │ └── .gitkeep │ │ ├── routes │ │ │ └── .gitkeep │ │ ├── styles │ │ │ └── app.css │ │ ├── components │ │ │ └── .gitkeep │ │ ├── controllers │ │ │ └── .gitkeep │ │ ├── templates │ │ │ ├── components │ │ │ │ └── .gitkeep │ │ │ └── application.hbs │ │ ├── resolver.js │ │ ├── app.d.ts │ │ ├── pods │ │ │ └── index │ │ │ │ └── route.js │ │ ├── router.js │ │ ├── app.js │ │ ├── config │ │ │ └── environment.d.ts │ │ └── index.html │ ├── config │ │ ├── optional-features.json │ │ ├── targets.js │ │ └── environment.js │ └── public │ │ ├── robots.txt │ │ └── crossdomain.xml ├── .eslintrc.js ├── test-helper.js ├── index.html └── acceptance │ └── container-keys-test.ts ├── .watchmanconfig ├── addon ├── index.ts └── utils │ └── debug-logger.ts ├── .bowerrc ├── .template-lintrc.js ├── .snyk ├── index.js ├── config ├── environment.js └── ember-try.js ├── .eslintignore ├── .ember-cli ├── tslint.json ├── .editorconfig ├── .gitignore ├── .npmignore ├── ember-cli-build.js ├── testem.js ├── tsconfig.json ├── LICENSE.md ├── .travis.yml ├── CHANGELOG.md ├── .eslintrc.js ├── package.json └── README.md /app/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/helpers/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/unit/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/dummy/app/helpers/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/dummy/app/models/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/dummy/app/routes/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/dummy/app/styles/app.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/dummy/app/components/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/dummy/app/controllers/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/dummy/app/templates/components/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.watchmanconfig: -------------------------------------------------------------------------------- 1 | { 2 | "ignore_dirs": ["tmp", "dist"] 3 | } 4 | -------------------------------------------------------------------------------- /addon/index.ts: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-debug-logger/utils/debug-logger'; 2 | -------------------------------------------------------------------------------- /.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "bower_components", 3 | "analytics": false 4 | } 5 | -------------------------------------------------------------------------------- /tests/dummy/config/optional-features.json: -------------------------------------------------------------------------------- 1 | { 2 | "jquery-integration": false 3 | } 4 | -------------------------------------------------------------------------------- /tests/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | embertest: true 4 | } 5 | }; 6 | -------------------------------------------------------------------------------- /tests/dummy/public/robots.txt: -------------------------------------------------------------------------------- 1 | # http://www.robotstxt.org 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /.template-lintrc.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: 'recommended' 5 | }; 6 | -------------------------------------------------------------------------------- /tests/dummy/app/templates/application.hbs: -------------------------------------------------------------------------------- 1 |

Welcome to Ember

2 | 3 | {{outlet}} 4 | -------------------------------------------------------------------------------- /tests/dummy/app/resolver.js: -------------------------------------------------------------------------------- 1 | import Resolver from 'ember-resolver'; 2 | 3 | export default Resolver; 4 | -------------------------------------------------------------------------------- /.snyk: -------------------------------------------------------------------------------- 1 | # Snyk (https://snyk.io) policy file 2 | version: v1.14.0 3 | 4 | exclude: 5 | global: 6 | - tests/** 7 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /* eslint-env node */ 2 | 'use strict'; 3 | 4 | module.exports = { 5 | name: require('./package').name, 6 | }; 7 | -------------------------------------------------------------------------------- /config/environment.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = function(/* environment, appConfig */) { 4 | return { }; 5 | }; 6 | -------------------------------------------------------------------------------- /tests/dummy/app/app.d.ts: -------------------------------------------------------------------------------- 1 | import Application from '@ember/application'; 2 | 3 | export default class App extends Application {} 4 | -------------------------------------------------------------------------------- /tests/dummy/app/pods/index/route.js: -------------------------------------------------------------------------------- 1 | import Route from '@ember/routing/route'; 2 | 3 | export default Route.extend({ 4 | activate() { 5 | this.debug('Hello from the application index.'); 6 | } 7 | }); 8 | -------------------------------------------------------------------------------- /tests/helpers/destroy-app.ts: -------------------------------------------------------------------------------- 1 | import Application from '@ember/application'; 2 | import { run } from '@ember/runloop'; 3 | 4 | export default function destroyApp(application: Application) { 5 | run(application, 'destroy'); 6 | } 7 | -------------------------------------------------------------------------------- /tests/test-helper.js: -------------------------------------------------------------------------------- 1 | import Application from '../app'; 2 | import config from '../config/environment'; 3 | import { setApplication } from '@ember/test-helpers'; 4 | import { start } from 'ember-qunit'; 5 | 6 | setApplication(Application.create(config.APP)); 7 | 8 | start(); 9 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | # unconventional js 2 | /blueprints/*/files/ 3 | /vendor/ 4 | 5 | # compiled output 6 | /dist/ 7 | /tmp/ 8 | 9 | # dependencies 10 | /bower_components/ 11 | 12 | # misc 13 | /coverage/ 14 | 15 | # ember-try 16 | /.node_modules.ember-try/ 17 | /bower.json.ember-try 18 | /package.json.ember-try 19 | -------------------------------------------------------------------------------- /tests/dummy/app/router.js: -------------------------------------------------------------------------------- 1 | import EmberRouter from '@ember/routing/router'; 2 | import config from './config/environment'; 3 | 4 | const Router = EmberRouter.extend({ 5 | location: config.locationType, 6 | rootURL: config.rootURL 7 | }); 8 | 9 | Router.map(function() { 10 | }); 11 | 12 | export default Router; 13 | -------------------------------------------------------------------------------- /.ember-cli: -------------------------------------------------------------------------------- 1 | { 2 | /** 3 | Ember CLI sends analytics information by default. The data is completely 4 | anonymous, but there are times when you might want to disable this behavior. 5 | 6 | Setting `disableAnalytics` to true will prevent any data from being sent. 7 | */ 8 | "disableAnalytics": false 9 | } 10 | -------------------------------------------------------------------------------- /tests/helpers/resolver.js: -------------------------------------------------------------------------------- 1 | import Resolver from '../../resolver'; 2 | import config from '../../config/environment'; 3 | 4 | const resolver = Resolver.create(); 5 | 6 | resolver.namespace = { 7 | modulePrefix: config.modulePrefix, 8 | podModulePrefix: config.podModulePrefix 9 | }; 10 | 11 | export default resolver; 12 | -------------------------------------------------------------------------------- /tests/dummy/config/targets.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const browsers = [ 4 | 'last 1 Chrome versions', 5 | 'last 1 Firefox versions', 6 | 'last 1 Safari versions' 7 | ]; 8 | 9 | const isCI = !!process.env.CI; 10 | const isProduction = process.env.EMBER_ENV === 'production'; 11 | 12 | if (isCI || isProduction) { 13 | browsers.push('ie 11'); 14 | } 15 | 16 | module.exports = { 17 | browsers 18 | }; 19 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "defaultSeverity": "error", 3 | "extends": [ 4 | "tslint:recommended" 5 | ], 6 | "jsRules": {}, 7 | "rules": { 8 | "quotemark": [true, "single"], 9 | "prefer-const": false, 10 | "object-literal-sort-keys": false, 11 | "interface-name": false, 12 | "only-arrow-functions": false, 13 | "no-unused-variable": true 14 | }, 15 | "rulesDirectory": [] 16 | } 17 | -------------------------------------------------------------------------------- /tests/dummy/app/app.js: -------------------------------------------------------------------------------- 1 | import Application from '@ember/application'; 2 | import Resolver from './resolver'; 3 | import loadInitializers from 'ember-load-initializers'; 4 | import config from './config/environment'; 5 | 6 | const App = Application.extend({ 7 | modulePrefix: config.modulePrefix, 8 | podModulePrefix: config.podModulePrefix, 9 | Resolver 10 | }); 11 | 12 | loadInitializers(App, config.modulePrefix); 13 | 14 | export default App; 15 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | 8 | [*] 9 | end_of_line = lf 10 | charset = utf-8 11 | trim_trailing_whitespace = true 12 | insert_final_newline = true 13 | indent_style = space 14 | indent_size = 2 15 | 16 | [*.hbs] 17 | insert_final_newline = false 18 | 19 | [*.{diff,md}] 20 | trim_trailing_whitespace = false 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist/ 5 | /tmp/ 6 | 7 | # dependencies 8 | /bower_components/ 9 | /node_modules/ 10 | 11 | # misc 12 | /.sass-cache 13 | /connect.lock 14 | /coverage/ 15 | /libpeerconnection.log 16 | /npm-debug.log* 17 | /testem.log 18 | /yarn-error.log 19 | 20 | # ember-try 21 | /.node_modules.ember-try/ 22 | /bower.json.ember-try 23 | /package.json.ember-try 24 | -------------------------------------------------------------------------------- /tests/dummy/app/config/environment.d.ts: -------------------------------------------------------------------------------- 1 | export default config; 2 | 3 | /** 4 | * Type declarations for 5 | * import config from './config/environment' 6 | * 7 | * For now these need to be managed by the developer 8 | * since different ember addons can materialize new entries. 9 | */ 10 | declare const config: { 11 | environment: any, 12 | modulePrefix: string, 13 | podModulePrefix: string, 14 | locationType: string, 15 | rootURL: string, 16 | APP: any, 17 | }; 18 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # compiled output 2 | /dist/ 3 | /tmp/ 4 | 5 | # dependencies 6 | /bower_components/ 7 | 8 | # misc 9 | /.bowerrc 10 | /.editorconfig 11 | /.ember-cli 12 | /.eslintignore 13 | /.eslintrc.js 14 | /.gitignore 15 | /.watchmanconfig 16 | /.travis.yml 17 | /bower.json 18 | /config/ember-try.js 19 | /ember-cli-build.js 20 | /testem.js 21 | /tests/ 22 | /yarn.lock 23 | .gitkeep 24 | 25 | # ember-try 26 | /.node_modules.ember-try/ 27 | /bower.json.ember-try 28 | /package.json.ember-try 29 | -------------------------------------------------------------------------------- /ember-cli-build.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const EmberAddon = require('ember-cli/lib/broccoli/ember-addon'); 4 | 5 | module.exports = function(defaults) { 6 | let app = new EmberAddon(defaults, { 7 | // Add options here 8 | }); 9 | 10 | /* 11 | This build file specifies the options for the dummy test app of this 12 | addon, located in `/tests/dummy` 13 | This build file does *not* influence how the addon or the app using it 14 | behave. You most likely want to be modifying `./index.js` or app's build file 15 | */ 16 | 17 | return app.toTree(); 18 | }; 19 | -------------------------------------------------------------------------------- /tests/helpers/start-app.ts: -------------------------------------------------------------------------------- 1 | import { merge } from '@ember/polyfills'; 2 | import { run } from '@ember/runloop'; 3 | import App from 'dummy/app'; 4 | import config from 'dummy/config/environment'; 5 | 6 | export default function startApp(attrs?: any): App { 7 | let attributes = merge({}, config.APP); 8 | attributes.autoboot = true; 9 | attributes = merge(attributes, attrs); // use defaults, but you can override; 10 | 11 | return run(() => { 12 | let application = App.create(attributes); 13 | application.setupForTesting(); 14 | application.injectTestHelpers(); 15 | return application as App; 16 | }); 17 | } 18 | -------------------------------------------------------------------------------- /tests/dummy/public/crossdomain.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 15 | 16 | -------------------------------------------------------------------------------- /testem.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | test_page: 'tests/index.html?hidepassed', 3 | disable_watching: true, 4 | launch_in_ci: [ 5 | 'Chrome' 6 | ], 7 | launch_in_dev: [ 8 | 'Chrome' 9 | ], 10 | browser_args: { 11 | Chrome: { 12 | ci: [ 13 | // --no-sandbox is needed when running Chrome inside a container 14 | process.env.CI ? '--no-sandbox' : null, 15 | '--headless', 16 | '--disable-gpu', 17 | '--disable-dev-shm-usage', 18 | '--disable-software-rasterizer', 19 | '--mute-audio', 20 | '--remote-debugging-port=0', 21 | '--window-size=1440,900' 22 | ].filter(Boolean) 23 | } 24 | } 25 | }; 26 | -------------------------------------------------------------------------------- /tests/helpers/module-for-acceptance.ts: -------------------------------------------------------------------------------- 1 | import { TestContext } from 'ember-test-helpers'; 2 | import { module } from 'qunit'; 3 | import { resolve } from 'rsvp'; 4 | import destroyApp from '../helpers/destroy-app'; 5 | import startApp from '../helpers/start-app'; 6 | 7 | export default function(name: string, options: Hooks = {}) { 8 | module(name, { 9 | beforeEach(this: TestContext) { 10 | this.application = startApp(); 11 | 12 | if (options.beforeEach) { 13 | return options.beforeEach.apply(this, arguments); 14 | } 15 | }, 16 | 17 | afterEach(this: TestContext) { 18 | let afterEach = options.afterEach && options.afterEach.apply(this, arguments); 19 | return resolve(afterEach).then(() => destroyApp(this.application)); 20 | }, 21 | }); 22 | } 23 | -------------------------------------------------------------------------------- /tests/dummy/app/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Dummy 7 | 8 | 9 | 10 | {{content-for "head"}} 11 | 12 | 13 | 14 | 15 | {{content-for "head-footer"}} 16 | 17 | 18 | {{content-for "body"}} 19 | 20 | 21 | 22 | 23 | {{content-for "body-footer"}} 24 | 25 | 26 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2017", 4 | "allowJs": true, 5 | "moduleResolution": "node", 6 | "allowSyntheticDefaultImports": true, 7 | "noImplicitThis": true, 8 | "noImplicitAny": true, 9 | "strictNullChecks": true, 10 | "strictPropertyInitialization": true, 11 | "noEmitOnError": false, 12 | "noEmit": true, 13 | "sourceMap": true, 14 | "baseUrl": ".", 15 | "module": "es6", 16 | "paths": { 17 | "dummy/tests/*": [ 18 | "tests/*" 19 | ], 20 | "dummy/*": [ 21 | "tests/dummy/app/*" 22 | ], 23 | "ember-debug-logger": [ 24 | "addon" 25 | ], 26 | "ember-debug-logger/*": [ 27 | "addon/*" 28 | ] 29 | } 30 | }, 31 | "include": [ 32 | "addon", 33 | "tests" 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /tests/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Dummy Tests 7 | 8 | 9 | 10 | {{content-for "head"}} 11 | {{content-for "test-head"}} 12 | 13 | 14 | 15 | 16 | 17 | {{content-for "head-footer"}} 18 | {{content-for "test-head-footer"}} 19 | 20 | 21 | {{content-for "body"}} 22 | {{content-for "test-body"}} 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | {{content-for "body-footer"}} 31 | {{content-for "test-body-footer"}} 32 | 33 | 34 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | language: node_js 3 | node_js: 4 | # we recommend testing addons with the same minimum supported node version as Ember CLI 5 | # so that your addon works for all apps 6 | - "6" 7 | 8 | sudo: false 9 | dist: trusty 10 | 11 | addons: 12 | chrome: stable 13 | 14 | cache: 15 | yarn: true 16 | 17 | env: 18 | global: 19 | # See https://git.io/vdao3 for details. 20 | - JOBS=1 21 | matrix: 22 | - EMBER_TRY_SCENARIO=ember-lts-2.16 23 | - EMBER_TRY_SCENARIO=ember-lts-2.18 24 | - EMBER_TRY_SCENARIO=ember-release 25 | - EMBER_TRY_SCENARIO=ember-beta 26 | - EMBER_TRY_SCENARIO=ember-canary 27 | - EMBER_TRY_SCENARIO=ember-default-with-jquery 28 | 29 | matrix: 30 | fast_finish: true 31 | allow_failures: 32 | - env: EMBER_TRY_SCENARIO=ember-canary 33 | 34 | before_install: 35 | - curl -o- -L https://yarnpkg.com/install.sh | bash 36 | - export PATH=$HOME/.yarn/bin:$PATH 37 | 38 | install: 39 | - yarn install --no-lockfile --non-interactive 40 | 41 | script: 42 | - yarn lint:js 43 | # Usually, it's ok to finish the test scenario without reverting 44 | # to the addon's original dependency state, skipping "cleanup". 45 | - node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO --skip-cleanup 46 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). 6 | 7 | ## Unreleased 8 | 9 | ## v2.1.1 - 04/09/2019 10 | 11 | This release fixes a bug introduced in `v2.1.0` — `debug@4` contains ES6 syntax that breaks compatibility with IE11. We now lock our `debug` dependency below version 4. 12 | 13 | ## v2.1.0 - 04/09/2019 14 | 15 | This release moved to pulling `debug` directly from npm and bringing it into the host application via `ember-auto-import` rather than the AMD build of `debug-dist`. 16 | 17 | ## v2.0.0 - 10/02/2018 18 | 19 | This release removes the automatic injection of the `debug` method on many container-owned objects. To migrate forward, you can either set `debug: debugLogger()` on those objects explicitly or reinstate the implicit injection in your own instance initializer: 20 | 21 | ```js 22 | export function initialize(instance) { 23 | instance.register('debug-logger:main', debugLogger(), { instantiate: false }); 24 | 25 | // Do this for each type you want the injection on 26 | instance.inject('route', 'debug', 'debug-logger:main'); 27 | } 28 | 29 | export default { 30 | name: 'debug-logger', 31 | initialize, 32 | }; 33 | ``` 34 | -------------------------------------------------------------------------------- /tests/unit/utils/debug-logger-test.ts: -------------------------------------------------------------------------------- 1 | import { A } from '@ember/array'; 2 | import debug from 'debug'; 3 | import debugLogger from 'ember-debug-logger'; 4 | import { module, test } from 'qunit'; 5 | import sinon, { SinonStub } from 'sinon'; 6 | 7 | module('Unit | Utility | debug logger', function(hooks) { 8 | let log: SinonStub; 9 | 10 | hooks.beforeEach(function() { 11 | debug.enable('test:sample-key'); 12 | log = sinon.stub(console, 'log'); 13 | }); 14 | 15 | hooks.afterEach(function() { 16 | debug.disable(); 17 | log.restore(); 18 | }); 19 | 20 | test('it honors an explicit key', function(assert) { 21 | const logger = debugLogger('test:sample-key'); 22 | logger('placeholder message'); 23 | 24 | let [message] = A(log.args).get('lastObject') || ['']; 25 | assert.ok(/test:sample-key/.test(message), 'Log entry should contain the namespace'); 26 | assert.ok(/placeholder message/.test(message), 'Log entry should contain the message'); 27 | }); 28 | 29 | test('it throws with a useful message when it can\'t determine a key', function(assert) { 30 | const logger = debugLogger(); 31 | 32 | assert.throws(function() { 33 | logger('message'); 34 | }, /explicit key/); 35 | 36 | assert.throws(function() { 37 | let object = { debug: logger }; 38 | object.debug('message'); 39 | }, /explicit key/); 40 | }); 41 | }); 42 | -------------------------------------------------------------------------------- /tests/dummy/config/environment.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = function(environment) { 4 | let ENV = { 5 | modulePrefix: 'dummy', 6 | environment, 7 | rootURL: '/', 8 | locationType: 'auto', 9 | EmberENV: { 10 | FEATURES: { 11 | // Here you can enable experimental features on an ember canary build 12 | // e.g. 'with-controller': true 13 | }, 14 | EXTEND_PROTOTYPES: { 15 | // Prevent Ember Data from overriding Date.parse. 16 | Date: false 17 | } 18 | }, 19 | 20 | APP: { 21 | // Here you can pass flags/options to your application instance 22 | // when it is created 23 | } 24 | }; 25 | 26 | if (environment === 'development') { 27 | // ENV.APP.LOG_RESOLVER = true; 28 | // ENV.APP.LOG_ACTIVE_GENERATION = true; 29 | // ENV.APP.LOG_TRANSITIONS = true; 30 | // ENV.APP.LOG_TRANSITIONS_INTERNAL = true; 31 | // ENV.APP.LOG_VIEW_LOOKUPS = true; 32 | } 33 | 34 | if (environment === 'test') { 35 | // Testem prefers this... 36 | ENV.locationType = 'none'; 37 | 38 | // keep test console output quieter 39 | ENV.APP.LOG_ACTIVE_GENERATION = false; 40 | ENV.APP.LOG_VIEW_LOOKUPS = false; 41 | 42 | ENV.APP.rootElement = '#ember-testing'; 43 | ENV.APP.autoboot = false; 44 | } 45 | 46 | if (environment === 'production') { 47 | // here you can enable a production-specific feature 48 | } 49 | 50 | return ENV; 51 | }; 52 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | parserOptions: { 4 | ecmaVersion: 2017, 5 | sourceType: 'module' 6 | }, 7 | plugins: [ 8 | 'ember' 9 | ], 10 | extends: [ 11 | 'eslint:recommended', 12 | 'plugin:ember/recommended' 13 | ], 14 | env: { 15 | browser: true 16 | }, 17 | rules: { 18 | }, 19 | overrides: [ 20 | // node files 21 | { 22 | files: [ 23 | '.template-lintrc.js', 24 | 'ember-cli-build.js', 25 | 'index.js', 26 | 'testem.js', 27 | 'blueprints/*/index.js', 28 | 'config/**/*.js', 29 | 'tests/dummy/config/**/*.js' 30 | ], 31 | excludedFiles: [ 32 | 'addon/**', 33 | 'addon-test-support/**', 34 | 'app/**', 35 | 'tests/dummy/app/**' 36 | ], 37 | parserOptions: { 38 | sourceType: 'script', 39 | ecmaVersion: 2015 40 | }, 41 | env: { 42 | browser: false, 43 | node: true 44 | }, 45 | plugins: ['node'], 46 | rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, { 47 | // add your custom rules and overrides for node files here 48 | }) 49 | }, 50 | 51 | // TypeScript files 52 | { 53 | files: ['**/*.ts'], 54 | parser: 'typescript-eslint-parser', 55 | rules: { 56 | // Handled by tsc 57 | 'no-undef': 'off', 58 | 'no-unused-vars': 'off' 59 | } 60 | } 61 | ] 62 | }; 63 | -------------------------------------------------------------------------------- /addon/utils/debug-logger.ts: -------------------------------------------------------------------------------- 1 | import debug, { IDebugger } from 'debug'; 2 | 3 | /** 4 | * Creates a function for debug logging, keyed by either an explicitly-given 5 | * namespace or the container key of the object it's attached to. 6 | * 7 | * Logging can then be enabled during debugging based on globbing of keys. 8 | * For instance, to enable logging for all routes, you could enter this in the 9 | * developer console: 10 | * debug.enable('route:*'); 11 | * 12 | * Or, to enable all logging: 13 | * debug.enable('*'); 14 | * 15 | * Logging preferences are persisted in local storage, and you'll need to reload 16 | * the page for changes to take effect. 17 | */ 18 | export default function debugLogger(key?: string): (formatter: any, ...args: any[]) => void { 19 | return key ? debug(key) : instanceLogger; 20 | } 21 | 22 | export function instanceLogger(this: LoggerContext | undefined) { 23 | let host = this; 24 | let logger = host && host._debugLoggerInstance; 25 | 26 | if (!logger) { 27 | const loggerKey = host && host._debugContainerKey; 28 | if (!loggerKey) { 29 | throw new Error('On non-container-managed objects, debug-logger requires an explicit key.'); 30 | } 31 | 32 | logger = debug(loggerKey); 33 | 34 | Object.defineProperty(this, '_debugLoggerInstance', { value: logger }); 35 | } 36 | 37 | return logger.apply(this, arguments); 38 | } 39 | 40 | export interface LoggerContext { 41 | _debugLoggerInstance?: IDebugger; 42 | _debugContainerKey?: string; 43 | } 44 | 45 | // For backwards compatibility and convenience in development, expose 46 | // `debug` as a global to make e.g. `debug.enable('*')` easy. 47 | // @ts-ignore 48 | window.debug = debug; 49 | -------------------------------------------------------------------------------- /tests/acceptance/container-keys-test.ts: -------------------------------------------------------------------------------- 1 | import Route from '@ember/routing/route'; 2 | import Service from '@ember/service'; 3 | import debug from 'debug'; 4 | import debugLogger from 'ember-debug-logger'; 5 | import { module, test } from 'qunit'; 6 | import { setupApplicationTest } from 'ember-qunit'; 7 | import sinon, { SinonStub } from 'sinon'; 8 | import { visit } from '@ember/test-helpers'; 9 | import { TestContext } from 'ember-test-helpers'; 10 | 11 | module('Acceptance | logging from container-managed objects', function(hooks) { 12 | let log: SinonStub; 13 | 14 | setupApplicationTest(hooks); 15 | 16 | hooks.beforeEach(function(this: TestContext) { 17 | this.owner.register('route:application', Route.extend({ debug: debugLogger() }), {}); 18 | this.owner.register('service:my/test/module', Service.extend({ debug: debugLogger() }), {}); 19 | 20 | debug.enable('route:*, service:*'); 21 | log = sinon.stub(console, 'log'); 22 | }); 23 | 24 | hooks.afterEach(function() { 25 | log.restore(); 26 | debug.disable(); 27 | }); 28 | 29 | test('it automatically finds keys when attached to container-managed objects', async function(assert) { 30 | await visit('/'); 31 | 32 | const appRoute = this.owner.lookup('route:application'); 33 | appRoute.debug('test message from the application route'); 34 | 35 | let [routeMessage] = log.lastCall.args; 36 | assert.ok(/route:application/.test(routeMessage), 'Route message should include its container key'); 37 | 38 | const testService = this.owner.lookup('service:my/test/module'); 39 | testService.debug('test message from the mysterious service'); 40 | 41 | let [serviceMessage] = log.lastCall.args; 42 | assert.ok(/service:my\/test\/module/.test(serviceMessage), 'Service message should include its container key'); 43 | }); 44 | }); 45 | -------------------------------------------------------------------------------- /config/ember-try.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const getChannelURL = require('ember-source-channel-url'); 4 | 5 | module.exports = function() { 6 | return Promise.all([ 7 | getChannelURL('release'), 8 | getChannelURL('beta'), 9 | getChannelURL('canary') 10 | ]).then((urls) => { 11 | return { 12 | scenarios: [ 13 | { 14 | name: 'ember-lts-2.16', 15 | env: { 16 | EMBER_OPTIONAL_FEATURES: JSON.stringify({ 'jquery-integration': true }), 17 | }, 18 | npm: { 19 | devDependencies: { 20 | '@ember/jquery': '^0.5.1', 21 | 'ember-source': '~2.16.0' 22 | } 23 | } 24 | }, 25 | { 26 | name: 'ember-lts-2.18', 27 | env: { 28 | EMBER_OPTIONAL_FEATURES: JSON.stringify({ 'jquery-integration': true }), 29 | }, 30 | npm: { 31 | devDependencies: { 32 | '@ember/jquery': '^0.5.1', 33 | 'ember-source': '~2.18.0' 34 | } 35 | } 36 | }, 37 | { 38 | name: 'ember-release', 39 | npm: { 40 | devDependencies: { 41 | 'ember-source': urls[0] 42 | } 43 | } 44 | }, 45 | { 46 | name: 'ember-beta', 47 | npm: { 48 | devDependencies: { 49 | 'ember-source': urls[1] 50 | } 51 | } 52 | }, 53 | { 54 | name: 'ember-canary', 55 | npm: { 56 | devDependencies: { 57 | 'ember-source': urls[2] 58 | } 59 | } 60 | }, 61 | { 62 | name: 'ember-default', 63 | npm: { 64 | devDependencies: {} 65 | } 66 | }, 67 | { 68 | name: 'ember-default-with-jquery', 69 | env: { 70 | EMBER_OPTIONAL_FEATURES: JSON.stringify({ 71 | 'jquery-integration': true 72 | }) 73 | }, 74 | npm: { 75 | devDependencies: { 76 | '@ember/jquery': '^0.5.1' 77 | } 78 | } 79 | } 80 | ] 81 | }; 82 | }); 83 | }; 84 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ember-debug-logger", 3 | "version": "2.1.1", 4 | "description": "An Ember addon to expose the Visionmedia debug logger.", 5 | "scripts": { 6 | "build": "ember build", 7 | "lint:hbs": "ember-template-lint .", 8 | "lint:js": "eslint . --ext js,ts", 9 | "start": "ember server", 10 | "test": "ember test", 11 | "prepublishOnly": "ember ts:precompile", 12 | "postpublish": "ember ts:clean", 13 | "test:all": "ember try:each" 14 | }, 15 | "engines": { 16 | "node": "6.* || 8.* || >= 10.*" 17 | }, 18 | "devDependencies": { 19 | "@ember/optional-features": "^0.6.3", 20 | "@types/ember": "*", 21 | "@types/ember-qunit": "^3.4.2", 22 | "@types/ember__test-helpers": "^0.7.5", 23 | "@types/qunit": "^2.0.31", 24 | "@types/rsvp": "^4.0.1", 25 | "@types/sinon": "^4.1.3", 26 | "broccoli-asset-rev": "^2.7.0", 27 | "ember-cli": "~3.4.2", 28 | "ember-cli-dependency-checker": "^3.0.0", 29 | "ember-cli-eslint": "^4.2.3", 30 | "ember-cli-htmlbars": "^3.0.0", 31 | "ember-cli-htmlbars-inline-precompile": "^1.0.3", 32 | "ember-cli-inject-live-reload": "^1.8.2", 33 | "ember-cli-qunit": "^4.3.2", 34 | "ember-cli-template-lint": "^1.0.0-beta.1", 35 | "ember-cli-typescript": "^1.4.2", 36 | "ember-cli-uglify": "^2.1.0", 37 | "ember-disable-prototype-extensions": "^1.1.3", 38 | "ember-load-initializers": "^1.1.0", 39 | "ember-maybe-import-regenerator": "^0.1.6", 40 | "ember-resolver": "^5.0.1", 41 | "ember-sinon": "^1.0.1", 42 | "ember-source": "~3.4.0", 43 | "ember-source-channel-url": "^1.1.0", 44 | "ember-try": "^1.0.0", 45 | "eslint-plugin-ember": "^5.2.0", 46 | "eslint-plugin-node": "^7.0.1", 47 | "loader.js": "^4.7.0", 48 | "qunit-dom": "^0.7.1", 49 | "typescript": "~3.0.1", 50 | "typescript-eslint-parser": "^19.0.2" 51 | }, 52 | "keywords": [ 53 | "ember-addon" 54 | ], 55 | "repository": { 56 | "type": "git", 57 | "url": "https://github.com/salsify/ember-debug-logger.git" 58 | }, 59 | "license": "MIT", 60 | "author": "Dan Freeman", 61 | "directories": { 62 | "doc": "doc", 63 | "test": "tests" 64 | }, 65 | "dependencies": { 66 | "@types/debug": "*", 67 | "debug": ">=2.0.0 <4.0.0", 68 | "ember-auto-import": "^1.2.21", 69 | "ember-cli-babel": "^7.6.0" 70 | }, 71 | "ember-addon": { 72 | "configPath": "tests/dummy/config" 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ember-debug-logger [![Build Status](https://travis-ci.org/salsify/ember-debug-logger.svg?branch=master)](https://travis-ci.org/salsify/ember-debug-logger) 2 | 3 | `ember-debug-logger` exposes the [visionmedia/debug](https://github.com/visionmedia/debug) library for use in your Ember.js application. 4 | 5 | Installation 6 | ------------------------------------------------------------------------------ 7 | 8 | `ember install ember-debug-logger` 9 | 10 | ## Usage 11 | 12 | The [debug library](https://github.com/visionmedia/debug) is available for standard use by import: 13 | 14 | ```js 15 | import debug from 'debug'; 16 | 17 | const log = debug('demo-namespace'); 18 | 19 | log('Hello, world'); 20 | ``` 21 | 22 | ![image](https://cloud.githubusercontent.com/assets/108688/8261895/117445f0-169c-11e5-913e-941e82dd2a52.png) 23 | 24 | ### Enabling Namespaces During Debugging 25 | 26 | 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. 27 | 28 | Enabled namespaces follow simple globbing rules, so to enable logging for everything, you could use: 29 | 30 | ```js 31 | debug.enable('*'); 32 | ``` 33 | 34 | To enable only logging coming from the application route: 35 | 36 | ```js 37 | debug.enable('route:application'); 38 | ``` 39 | 40 | You can mix and match as well. To enable logging for all routes and the `foo-bar` service, for instance: 41 | 42 | ```js 43 | debug.enable('route:*, service:foo-bar'); 44 | ``` 45 | 46 | You can turn off all logging with `disable`: 47 | 48 | ``` 49 | debug.disable(); 50 | ``` 51 | 52 | Namespaces will automatically be differentiated by color, and the time between messages will be logged. 53 | 54 | ![image](https://cloud.githubusercontent.com/assets/108688/8263047/624cd006-16a5-11e5-9ba8-bd67d5ce5d7b.png) 55 | 56 | 57 | ### Automatic Namespacing 58 | 59 | This addon exports a `debugLogger` function you can attach to a class definition. The resulting method will automatically use its instance's container key as the namespace. 60 | 61 | ```js 62 | // app/routes/index.js 63 | import Route from '@ember/route'; 64 | import debugLogger from 'ember-debug-logger'; 65 | 66 | export default Route.extend({ 67 | debug: debugLogger(); 68 | 69 | activate() { 70 | this.debug('Hello from the application index.'); 71 | } 72 | }); 73 | ``` 74 | 75 | ![image](https://cloud.githubusercontent.com/assets/108688/8262107/e0e71bb8-169d-11e5-9b74-9a895ed7e418.png) 76 | --------------------------------------------------------------------------------