diff --git a/packages/@ember/deprecated-features/index.ts b/packages/@ember/deprecated-features/index.ts index 76952cd5dcf..fa0ea336408 100644 --- a/packages/@ember/deprecated-features/index.ts +++ b/packages/@ember/deprecated-features/index.ts @@ -5,3 +5,4 @@ export const DEPRECATE_ID_MISSING = !!'2.1.0-beta.1'; export const DEPRECATE_UNTIL_MISSING = !!'2.1.0-beta.1'; export const RUN_SYNC = !!'3.0.0-beta.4'; export const REGISTRY_RESOLVER_AS_FUNCTION = !!'2.3.0-beta.3'; +export const LOGGER = !!'3.2.0-beta.1'; diff --git a/packages/ember-console/index.js b/packages/ember-console/index.js index 5dadfed3e8d..a5d8b83e57a 100644 --- a/packages/ember-console/index.js +++ b/packages/ember-console/index.js @@ -1,4 +1,5 @@ import { deprecate } from '@ember/debug'; +import { LOGGER } from '@ember/deprecated-features'; // Deliver message that the function is deprecated @@ -9,6 +10,7 @@ const DEPRECATION_URL = /** @module ember */ + /** Inside Ember-Metal, simply uses the methods from `imports.console`. Override this to provide more robust logging functionality. @@ -19,8 +21,11 @@ const DEPRECATION_URL = @namespace Ember @public */ -export default { - /** +let DEPRECATED_LOGGER; + +if (LOGGER) { + DEPRECATED_LOGGER = { + /** Logs the arguments to the console. You can pass as many arguments as you want and they will be joined together with a space. @@ -35,16 +40,16 @@ export default { @param {*} arguments @public */ - log() { - deprecate(DEPRECATION_MESSAGE, false, { - id: DEPRECATION_ID, - until: '4.0.0', - url: DEPRECATION_URL, - }); - return console.log(...arguments); // eslint-disable-line no-console - }, - - /** + log() { + deprecate(DEPRECATION_MESSAGE, false, { + id: DEPRECATION_ID, + until: '4.0.0', + url: DEPRECATION_URL, + }); + return console.log(...arguments); // eslint-disable-line no-console + }, + + /** Prints the arguments to the console with a warning icon. You can pass as many arguments as you want and they will be joined together with a space. @@ -58,16 +63,16 @@ export default { @param {*} arguments @public */ - warn() { - deprecate(DEPRECATION_MESSAGE, false, { - id: DEPRECATION_ID, - until: '4.0.0', - url: DEPRECATION_URL, - }); - return console.warn(...arguments); // eslint-disable-line no-console - }, - - /** + warn() { + deprecate(DEPRECATION_MESSAGE, false, { + id: DEPRECATION_ID, + until: '4.0.0', + url: DEPRECATION_URL, + }); + return console.warn(...arguments); // eslint-disable-line no-console + }, + + /** Prints the arguments to the console with an error icon, red text and a stack trace. You can pass as many arguments as you want and they will be joined together with a space. @@ -81,16 +86,16 @@ export default { @param {*} arguments @public */ - error() { - deprecate(DEPRECATION_MESSAGE, false, { - id: DEPRECATION_ID, - until: '4.0.0', - url: DEPRECATION_URL, - }); - return console.error(...arguments); // eslint-disable-line no-console - }, - - /** + error() { + deprecate(DEPRECATION_MESSAGE, false, { + id: DEPRECATION_ID, + until: '4.0.0', + url: DEPRECATION_URL, + }); + return console.error(...arguments); // eslint-disable-line no-console + }, + + /** Logs the arguments to the console. You can pass as many arguments as you want and they will be joined together with a space. @@ -105,16 +110,16 @@ export default { @param {*} arguments @public */ - info() { - deprecate(DEPRECATION_MESSAGE, false, { - id: DEPRECATION_ID, - until: '4.0.0', - url: DEPRECATION_URL, - }); - return console.info(...arguments); // eslint-disable-line no-console - }, - - /** + info() { + deprecate(DEPRECATION_MESSAGE, false, { + id: DEPRECATION_ID, + until: '4.0.0', + url: DEPRECATION_URL, + }); + return console.info(...arguments); // eslint-disable-line no-console + }, + + /** Logs the arguments to the console in blue text. You can pass as many arguments as you want and they will be joined together with a space. @@ -129,21 +134,21 @@ export default { @param {*} arguments @public */ - debug() { - deprecate(DEPRECATION_MESSAGE, false, { - id: DEPRECATION_ID, - until: '4.0.0', - url: DEPRECATION_URL, - }); - /* eslint-disable no-console */ - if (console.debug) { - return console.debug(...arguments); - } - return console.info(...arguments); - /* eslint-enable no-console */ - }, - - /** + debug() { + deprecate(DEPRECATION_MESSAGE, false, { + id: DEPRECATION_ID, + until: '4.0.0', + url: DEPRECATION_URL, + }); + /* eslint-disable no-console */ + if (console.debug) { + return console.debug(...arguments); + } + return console.info(...arguments); + /* eslint-enable no-console */ + }, + + /** If the value passed into `Ember.Logger.assert` is not truthy it will throw an error with a stack trace. ```javascript @@ -158,12 +163,15 @@ export default { @param {String} message Assertion message on failed @public */ - assert() { - deprecate(DEPRECATION_MESSAGE, false, { - id: DEPRECATION_ID, - until: '4.0.0', - url: DEPRECATION_URL, - }); - return console.assert(...arguments); // eslint-disable-line no-console - }, -}; + assert() { + deprecate(DEPRECATION_MESSAGE, false, { + id: DEPRECATION_ID, + until: '4.0.0', + url: DEPRECATION_URL, + }); + return console.assert(...arguments); // eslint-disable-line no-console + }, + }; +} + +export default DEPRECATED_LOGGER; diff --git a/packages/ember/index.js b/packages/ember/index.js index 062391dad03..73b04a64ff2 100644 --- a/packages/ember/index.js +++ b/packages/ember/index.js @@ -125,7 +125,7 @@ import Map from '@ember/map'; import MapWithDefault from '@ember/map/with-default'; import OrderedSet from '@ember/map/lib/ordered-set'; import { assign, merge } from '@ember/polyfills'; -import { EMBER_EXTEND_PROTOTYPES } from '@ember/deprecated-features'; +import { LOGGER, EMBER_EXTEND_PROTOTYPES } from '@ember/deprecated-features'; // ****ember-environment**** @@ -355,7 +355,9 @@ Object.defineProperty(Ember, 'testing', { Ember._Backburner = Backburner; // ****ember-console**** -Ember.Logger = Logger; +if (LOGGER) { + Ember.Logger = Logger; +} // ****ember-runtime**** Ember.A = A;