8000 [RFC] Extract the built-in Logger to a separate component · Issue #59527 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[RFC] Extract the built-in Logger to a separate component #59527

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

Closed
phansys opened this issue Jan 16, 2025 · 8 comments
Closed

[RFC] Extract the built-in Logger to a separate component #59527

phansys opened this issue Jan 16, 2025 · 8 comments
Labels
RFC RFC = Request For Comments (proposals about features that you want to be discussed)

Comments

@phansys
Copy link
Contributor
phansys commented Jan 16, 2025

Description

This RFC proposes to move the built-in PSR-3 Logger to its own component.

The reasoning behind this proposal is maybe wider

  • From the decoupled perspective, Symfony is a set of reusable PHP components.
  • From the framework perspective, Symfony is a PHP framework for web projects.

Given these assertions, the provided logger may be used even in pure CLI applications, where the HTTP context does not even exist. That's why I found weird that the logger is provided by a component that uses the HTTP term in its name.

Example

namespace Symfony\Component\Logger;

class Logger extends AbstractLogger implements DebugLoggerInterface
{
    // ...
}
@carsonbot carsonbot added the RFC RFC = Request For Comments (proposals about features that you want to be discussed) label Jan 16, 2025
@stloyd
Copy link
Contributor
stloyd commented Jan 16, 2025

But this logger is not a component. It's based on PSR and is just for the HttpKernel component, as its code is hardly bound to that component. There is almost nothing that could be useful about having this logger as a component.

PSR abstract implementation or Monolog are perfect components that are already re-usable.

@stof
Copy link
Member

And this DebugLoggerInterface is related to the profiler to collect logs (and the profiler is part of the HttpKernel component)

@phansys
Copy link
Contributor Author
phansys commented Jan 17, 2025

Sure. I think both assertions are great describing the current implementation.
That's why the goal of this RFC is to change the mentioned bound / coupling.

@GromNaN
Copy link
Member
GromNaN commented Jan 17, 2025

Given these assertions, the provided logger may be used even in pure CLI applications, where the HTTP context does not even exist. That's why I found weird that the logger is provided by a component that uses the HTTP term in its name.

For CLI applications, you can use the Console Logger.

@stof
Copy link
Member
stof commented Jan 17, 2025

@phansys if we extract this logger without the parts coupled to HttpKernel, the class would be a very basic PSR-3 implementation writing to STDERR. This does not warrant a dedicated component IMO.

And we don't want to create a logger component supporting more advanced cases either (that's already handled properly by Monolog). This component would also not be defining a logger contract as we rely on the PSR-3 LoggerInterface for that.

@phansys
Copy link
Contributor Author
phansys commented Jan 17, 2025

For CLI applications, you can use the Console Logger.

Good point, I didn't remember this.

Could we then add a note in the Logging docs about the intended usage for each one of these loggers?

If you agree, I can create a PR. Thank you!

@GromNaN
Copy link
Member
GromNaN commented Jan 17, 2025

Yes mentioning the Console Logger on this page would be a good idea.

@fabpot
Copy link
Member
fabpot commented Jan 18, 2025

Closing as it seems we agree that this won't happen.

@fabpot fabpot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 18, 2025
javiereguiluz added a commit to symfony/symfony-docs that referenced this issue Jan 22, 2025
This PR was submitted for the 7.1 branch but it was merged into the 6.4 branch instead.

Discussion
----------

[Logging] Add references to the `ConsoleLogger`

See symfony/symfony#59527.

Commits
-------

b9c7139 [Logging] Add references to the `ConsoleLogger`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFC RFC = Request For Comments (proposals about features that you want to be discussed)
Projects
None yet
Development

No branches or pull requests

6 participants
0