From 22c4f6dc0c5cd25c6f6a2d3b38ec2c5613c7d406 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Czy=C5=BC?= Date: Tue, 29 Jan 2019 19:32:42 +0100 Subject: [PATCH] fix: #237 - replacing `Ember.Logger` with `console` (#266) --- addon/-task-instance.js | 9 ++++++--- addon/-task-property.js | 4 ++-- tests/unit/deprecations-test.js | 8 ++++---- tests/unit/task-test.js | 17 +++++++++-------- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/addon/-task-instance.js b/addon/-task-instance.js index c40553c9a..6bc8644a2 100644 --- a/addon/-task-instance.js +++ b/addon/-task-instance.js @@ -415,7 +415,8 @@ let taskInstanceAttrs = { value = new Error(this.cancelReason); if (this._debug || Ember.ENV.DEBUG_TASKS) { - Ember.Logger.log(this.cancelReason); + // eslint-disable-next-line no-console + console.log(this.cancelReason); } value.name = TASK_CANCELATION_NAME; @@ -544,7 +545,8 @@ let taskInstanceAttrs = { } finally { if (this._expectsLinkedYield) { if (!this._generatorValue || this._generatorValue._performType !== PERFORM_TYPE_LINKED) { - Ember.Logger.warn("You performed a .linked() task without immediately yielding/returning it. This is currently unsupported (but might be supported in future version of ember-concurrency)."); + // eslint-disable-next-line no-console + console.warn("You performed a .linked() task without immediately yielding/returning it. This is currently unsupported (but might be supported in future version of ember-concurrency)."); } this._expectsLinkedYield = false; } @@ -783,7 +785,8 @@ taskInstanceAttrs[yieldableSymbol] = function handleYieldedTaskInstance(parentTa get(yieldedTaskInstance, 'isRunning')) { let parentName = `\`${parentTaskInstance.task._propertyName}\``; let childName = `\`${yieldedTaskInstance.task._propertyName}\``; - Ember.Logger.warn(`ember-concurrency detected a potentially hazardous "self-cancel loop" between parent task ${parentName} and child task ${childName}. If you want child task ${childName} to be canceled when parent task ${parentName} is canceled, please change \`.perform()\` to \`.linked().perform()\`. If you want child task ${childName} to keep running after parent task ${parentName} is canceled, change it to \`.unlinked().perform()\``); + // eslint-disable-next-line no-console + console.warn(`ember-concurrency detected a potentially hazardous "self-cancel loop" between parent task ${parentName} and child task ${childName}. If you want child task ${childName} to be canceled when parent task ${parentName} is canceled, please change \`.perform()\` to \`.linked().perform()\`. If you want child task ${childName} to keep running after parent task ${parentName} is canceled, change it to \`.unlinked().perform()\``); } } yieldedTaskInstance.cancel(); diff --git a/addon/-task-property.js b/addon/-task-property.js index 48428ed5b..eac00d7b0 100644 --- a/addon/-task-property.js +++ b/addon/-task-property.js @@ -3,7 +3,6 @@ import { addObserver } from '@ember/object/observers'; import { addListener } from '@ember/object/events'; import EmberObject from '@ember/object'; import { getOwner } from '@ember/application'; -import Ember from 'ember'; import { default as TaskInstance, getRunningInstance @@ -442,7 +441,8 @@ export class TaskProperty extends _ComputedProperty { super.setup(...arguments); } if (this._maxConcurrency !== Infinity && !this._hasSetBufferPolicy) { - Ember.Logger.warn(`The use of maxConcurrency() without a specified task modifier is deprecated and won't be supported in future versions of ember-concurrency. Please specify a task modifier instead, e.g. \`${taskName}: task(...).enqueue().maxConcurrency(${this._maxConcurrency})\``); + // eslint-disable-next-line no-console + console.warn(`The use of maxConcurrency() without a specified task modifier is deprecated and won't be supported in future versions of ember-concurrency. Please specify a task modifier instead, e.g. \`${taskName}: task(...).enqueue().maxConcurrency(${this._maxConcurrency})\``); } registerOnPrototype(addListener, proto, this.eventNames, taskName, 'perform', false); diff --git a/tests/unit/deprecations-test.js b/tests/unit/deprecations-test.js index d5a987296..dac12c630 100644 --- a/tests/unit/deprecations-test.js +++ b/tests/unit/deprecations-test.js @@ -1,22 +1,22 @@ +/* eslint-disable no-console */ import { run } from '@ember/runloop'; import EmberObject from '@ember/object'; -import Ember from 'ember'; import { task } from 'ember-concurrency'; import { module, test } from 'qunit'; -const originalWarn = Ember.Logger.warn; +const originalWarn = console.warn; let warnings; module('Deprecations', function(hooks) { hooks.beforeEach(function() { warnings = []; - Ember.Logger.warn = (w) => { + console.warn = (w) => { warnings.push(w); }; }); hooks.afterEach(function() { - Ember.Logger.warn = originalWarn; + console.warn = originalWarn; }); test("warn if using maxConcurrency without specifying other task modifier", function(assert) { diff --git a/tests/unit/task-test.js b/tests/unit/task-test.js index 38e72a673..836ac143a 100644 --- a/tests/unit/task-test.js +++ b/tests/unit/task-test.js @@ -1,3 +1,4 @@ +/* eslint-disable no-console */ import { defer } from 'rsvp'; import { A } from '@ember/array'; import Evented from '@ember/object/evented'; @@ -7,13 +8,13 @@ import Ember from 'ember'; import { task, timeout, forever } from 'ember-concurrency'; import { module, test } from 'qunit'; -const originalLog = Ember.Logger.log; -const originalWarn = Ember.Logger.warn; +const originalLog = console.log; +const originalWarn = console.warn; module('Unit: task', function(hooks) { hooks.afterEach(function() { - Ember.Logger.log = originalLog; - Ember.Logger.warn = originalWarn; + console.log = originalLog; + console.warn = originalWarn; Ember.ENV.DEBUG_TASKS = false; }); @@ -452,7 +453,7 @@ module('Unit: task', function(hooks) { assert.expect(1); let logs = []; - Ember.Logger.log = (...args) => { + console.log = (...args) => { logs.push(args); }; @@ -481,7 +482,7 @@ module('Unit: task', function(hooks) { Ember.ENV.DEBUG_TASKS = true; let logs = []; - Ember.Logger.log = (...args) => { + console.log = (...args) => { logs.push(args); }; @@ -535,7 +536,7 @@ module('Unit: task', function(hooks) { assert.expect(2); let warnings = []; - Ember.Logger.warn = (...args) => { + console.warn = (...args) => { warnings.push(args); }; @@ -606,7 +607,7 @@ module('Unit: task', function(hooks) { assert.expect(1); let warnings = []; - Ember.Logger.warn = (...args) => { + console.warn = (...args) => { warnings.push(args); };