-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC 297] Deprecation of Ember.Logger #16250
Conversation
Four tests failed because the change I made to the debug() method in ember-debug/lib/index.js didn't fare well in Edge and IE11. I'll hop on Windows and nail it down in the morning. |
This has been interesting. There are 20 tests that fail only in Edge and IE11- and only when you don't have the developer tools up. The point of failure lies in precisely two lines of code in the source. The first occurs with The second occurs doing |
Someone please review packages\ember-routing\lib\system\router.js line 1193 - I debated between ease of understanding and absolute performance here - should it be yanked to the top of the module to be created once? How critical is that? I'll still chase something more elegant once I figure out how Edge is defining the console differently with devtools closed, but this approach turns clearly failing tests to consistently passing tests, at least on my Windows box. |
packages/ember-console/lib/index.js
Outdated
deprecate( | ||
'Use of Ember.Logger is deprecated. Please use `console` for logging.', | ||
false, | ||
{ id: 'ember-console.deprecate-logger', until: '3.5.0', url: 'https://emberjs.com/deprecations/v3.x#toc_use-console-rather-than-ember-logger' } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the until
should be 4.0.0
.
packages/ember-console/lib/index.js
Outdated
import { deprecate } from 'ember-debug'; | ||
|
||
// Deliver message that the function is deprecated | ||
let deprecateEmberLogger = function(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I definitely appreciate the desire to be a bit DRY here, but the current implementation has a larger footprint in production builds (where the deprecation is stripped). Would you mind inlining the deprecation in each of the methods instead (I am sorry that we can’t have nice things...)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See if you like the approach I just checked in - I've split the difference to ensure that repeatedly typing long strings can't result in unnecessary and hard-to-spot differences, while still calling deprecate clearly in each method.
packages/ember-debug/lib/index.js
Outdated
@@ -130,7 +136,9 @@ if (DEBUG) { | |||
@private | |||
*/ | |||
setDebugFunction('info', function info() { | |||
Logger.info.apply(undefined, arguments); | |||
/* eslint-disable no-console */ | |||
console.info.apply(console, arguments); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do console.info(...arguments)
here instead?
packages/ember-debug/lib/index.js
Outdated
@@ -130,7 +136,9 @@ if (DEBUG) { | |||
@private | |||
*/ | |||
setDebugFunction('info', function info() { | |||
Logger.info.apply(undefined, arguments); | |||
/* eslint-disable no-console */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@for some of these disablings you may be able to make it a tad less noisy via // eslint-disable-next-line no-console
packages/ember-debug/lib/warn.js
Outdated
} | ||
/* eslint-disable no-console */ | ||
console.warn(`WARNING: ${message}`); //eslint-disable-line no-console | ||
// VERIFY! if ('trace' in Logger) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can probably kill this comment
packages/ember-debug/lib/warn.js
Outdated
Logger.trace(); | ||
} | ||
/* eslint-disable no-console */ | ||
console.warn(`WARNING: ${message}`); //eslint-disable-line no-console |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this comment isn’t needed (since the surrounding ones should do the trick)
@@ -106,7 +105,13 @@ const EmberRouter = EmberObject.extend(Evented, { | |||
|
|||
if (DEBUG) { | |||
if (get(this, 'namespace.LOG_TRANSITIONS_INTERNAL')) { | |||
routerMicrolib.log = Logger.debug; | |||
/* eslint-disable no-console */ | |||
if (console.debug) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets remove this, and just use console.log
version only
@@ -1181,7 +1189,7 @@ function logError(_error, initialMessage) { | |||
if (typeof error === 'string') { errorArgs.push(error); } | |||
} | |||
|
|||
Logger.error.apply(this, errorArgs); | |||
console.error.apply(console, errorArgs); //eslint-disable-line no-console |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you update this to console.error(...errorArgs)
instead?
|
||
originalLoggerError = Logger.error; | ||
originalLoggerError = console.error; // eslint-disable-line no-console |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also update the variable name here (so it doesn't refer to logger)?
Logger.log.apply(null, positional.value()); | ||
} | ||
/* eslint-disable no-console */ | ||
console.log.apply(console, positional.value()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you modify to console.log(...positional.value())
?
Sorry for the big stack of stuff - shouldn't be much actual change - I sync'd up my fork/master and rebased the branch... no conflicts reported and everything tested out fine - this should have everything you requested... |
cc425c7
to
4bbb29b
Compare
4bbb29b
to
da5b58e
Compare
🎉 |
Thanks @lupestro for all the hard work on this! |
I've implemented the changes to the project. Since Ember itself no longer uses Ember.Logger, this PR could perhaps use one more test that deliberately calls the methods to verify that the console is reporting deprecation. Otherwise, this should be set to go.