Skip to content

Commit

Permalink
Wrap Ember.Logger for svelting...
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjblue committed May 24, 2018
1 parent 553af3a commit 2eba9e2
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 68 deletions.
1 change: 1 addition & 0 deletions packages/@ember/deprecated-features/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
140 changes: 74 additions & 66 deletions packages/ember-console/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { deprecate } from '@ember/debug';
import { LOGGER } from '@ember/deprecated-features';

// Deliver message that the function is deprecated

Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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
Expand All @@ -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;
6 changes: 4 additions & 2 deletions packages/ember/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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****

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 2eba9e2

Please sign in to comment.