-
-
Notifications
You must be signed in to change notification settings - Fork 407
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
Deprecating Ember.Logger #297
Conversation
RFC to deprecate the Ember.Logger that currently lives in ember-console. I'm new to this process and this is a preliminary draft, so please be gentle. :-}
…ed eslint no-console issue
I support this change. Happy to help implement as well. |
This is good, and it looks like a nicely separable piece of work that doesn't require any deep experience with ember internals. |
text/0297-deprecate-ember-logger.md
Outdated
their own logging service. If we encourage the use of a Babel plugin | ||
to strip console calls, should we remove `no-console` from the default | ||
flags that `ember-cli` ships? | ||
How do we deal with `Logger.debug` in the codemod? |
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.
A suggestion: Try making the question a sub-header and not use bullet points for all of the answer.
text/0297-deprecate-ember-logger.md
Outdated
`Logger.warn`, so the `ember-debug` code should be changed _first_ or adding | ||
the deprecation warning will create a deep recursion. | ||
|
||
The log and debug messages emitted by Ember for deprecations and assertions |
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.
You might want to slightly rephrase this section to specifically indicate that it is Ember.warn
and friends that are noops in production.
What happens in the situation where the For example, my app has an initializer that sends all log messages to Rollbar. Here is what it looks like for the
How would I change this code in light of this RFC? Would I just override |
@paulyoder I would think you'd just override |
I think this makes sense. As far as the eslint question, I personally wouldn't want to turn off no-console: ["error", { allow: ["info", "warn", "error"] }] This gives me a good set of options for logging to the console, but also allows me to use Personally, I'd advocate for something like ☝️ over just disabling |
I think that separate from this RFC, it would be nice to have another RFC that deals with the "debugging and logging story" of ember. I think this is where a lot of these kinds of issues could come out, and you could tap into some parts of ember and other extensible tools to get a richer logging and debugging experience. |
@webark send that RFC over ;) |
@lupestro - Great job putting this together!! I only have a few responses to the unanswered questions section:
I think replacing it with
I think we do nothing. Leaving |
We discussed this at the core team meeting today, and we are general happy to move forward on this RFC. Since it seems like conversation has largely settled here, we are moving it into the final comment period. |
I'm the proud maintainer of the addon with the most uses of |
Currently, the best recommendation I can think of is to build a small wrapper of your own, preferably as a service suitable for dependency injection, possibly even available to your clients for interception. (Ember.Logger itself has something like a single functional line for each kind of console call it performs, so your wrapper shouldn't need to be any bigger.) I'm hoping other reviewers will have a better suggestion. I'll make sure the best suggestion makes it into the deprecation guide, since this is a question that is likely to be asked a lot. Should I say anything in the RFC text at this late date? |
Was the option 2 considered as a bridge, or will that just prolong the pain?
|
@MelSumner - I think that is likely fine but under a different name (e.g. @machty - I believe that the answer here is more situational (e.g. it depends how an addon uses
|
Thanks to everyone for participating in this RFC! After discussion with the core team, we are 👍 on moving forward here. |
Originally (Ember < 3.2), `Ember.warn` used `Ember.Logger` as an abstraction layer in case `console` was not present. Since `Ember.Logger` was deprecated in [emberjs/rfcs#297](https://emberjs.github.io/rfcs/0297-deprecate-ember-logger.html) the internals have been refactored to use `console` directly instead. When that change was made, the following: ```js Logger.warn(`WARNING: ${message}`); if ('trace' in Logger) { Logger.trace(); } ``` Was changed to: ```js console.warn(`WARNING: ${message}`); if (console.trace) { console.trace(); } ``` This _seems_ correct, however when you dig into it you will notice that the `Ember.Logger` class **never** had a `.trace` method! The reason for the original `'trace' in Logger` check was specifically so that you _could_ do `Ember.Logger.trace = () => console.trace` _IIF_ you wanted to see where a given warning was coming from. That was added back in 2012, but since then the developer tools of modern browsers have gotten massively better. At this point, **every** `console.log`/`console.warn` tracks its stack trace so that you can drill into the source in the dev tools. The primary difference between that functionality and calling `console.trace()` directly like this is that with `console.warn` the stack trace is hidden by default (and has to be manually expanded), whereas with `console.trace()` it is _always_ called and the full stack is printed. Ultimately, this means that when we refactored to address the `Ember.Logger` deprecation, we began calling `console.trace` for _every_ `Ember.warn` invocation and the `console.trace()` calls make the console fairly unusable even with a very low volumn of warnings.
Originally (Ember < 3.2), `Ember.warn` used `Ember.Logger` as an abstraction layer in case `console` was not present. Since `Ember.Logger` was deprecated in [emberjs/rfcs#297](https://emberjs.github.io/rfcs/0297-deprecate-ember-logger.html) the internals have been refactored to use `console` directly instead. When that change was made, the following: ```js Logger.warn(`WARNING: ${message}`); if ('trace' in Logger) { Logger.trace(); } ``` Was changed to: ```js console.warn(`WARNING: ${message}`); if (console.trace) { console.trace(); } ``` This _seems_ correct, however when you dig into it you will notice that the `Ember.Logger` class **never** had a `.trace` method! The reason for the original `'trace' in Logger` check was specifically so that you _could_ do `Ember.Logger.trace = () => console.trace` _IIF_ you wanted to see where a given warning was coming from. That was added back in 2012, but since then the developer tools of modern browsers have gotten massively better. At this point, **every** `console.log`/`console.warn` tracks its stack trace so that you can drill into the source in the dev tools. The primary difference between that functionality and calling `console.trace()` directly like this is that with `console.warn` the stack trace is hidden by default (and has to be manually expanded), whereas with `console.trace()` it is _always_ called and the full stack is printed. Ultimately, this means that when we refactored to address the `Ember.Logger` deprecation, we began calling `console.trace` for _every_ `Ember.warn` invocation and the `console.trace()` calls make the console fairly unusable even with a very low volumn of warnings. (cherry picked from commit 3e45eb9)
This is the RFC for the work to deprecate Ember.Logger.
Rendered.