Skip to content
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

Merged
merged 2 commits into from
Mar 9, 2018

Conversation

lupestro
Copy link

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.

@lupestro
Copy link
Author

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.

@lupestro
Copy link
Author

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 (console.debug ? console.debug : console.log)(params), which was easy to work around by replacing the operator with an actual if/else, but the workaround only fixes one test case. The failure gave a pretty strong hint of at least part of what's going on - when Edge isn't in devtools, I think we're dealing with a bound member function of an object - but I need to investigate further.

The second occurs doing console.error.apply(this, errorArgs) in one spot in the router, and is responsible for at least 18 and probably all 19 of the remaining cases. I can shim around that by wrapping a call to console.error in an un-exported tiny logger shim class for the router only to use. With a little deeper understanding, I can probably do better still, and have a great topic for a blog post from it, so I'm going to pursue that. However, I'll do the shim first, since I know that will work.

@lupestro
Copy link
Author

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.

locks
locks previously requested changes Feb 19, 2018
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' }
Copy link
Contributor

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.

import { deprecate } from 'ember-debug';

// Deliver message that the function is deprecated
let deprecateEmberLogger = function(){
Copy link
Member

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...)?

Copy link
Author

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.

@@ -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);
Copy link
Member

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?

@@ -130,7 +136,9 @@ if (DEBUG) {
@private
*/
setDebugFunction('info', function info() {
Logger.info.apply(undefined, arguments);
/* eslint-disable no-console */
Copy link
Member

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

}
/* eslint-disable no-console */
console.warn(`WARNING: ${message}`); //eslint-disable-line no-console
// VERIFY! if ('trace' in Logger) {
Copy link
Member

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

Logger.trace();
}
/* eslint-disable no-console */
console.warn(`WARNING: ${message}`); //eslint-disable-line no-console
Copy link
Member

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) {
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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());
Copy link
Member

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())?

@lupestro
Copy link
Author

lupestro commented Mar 2, 2018

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...

@rwjblue rwjblue dismissed locks’s stale review March 9, 2018 20:48

addressed feedback

@rwjblue rwjblue merged commit 76dc4de into emberjs:master Mar 9, 2018
@rwjblue
Copy link
Member

rwjblue commented Mar 9, 2018

🎉

@rwjblue
Copy link
Member

rwjblue commented Mar 9, 2018

Thanks @lupestro for all the hard work on this!

@lupestro lupestro deleted the deprecate-ember-logger branch March 13, 2018 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants