yiisoft / yii2

Yii 2: The Fast, Secure and Professional PHP Framework
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
14.24k stars 6.91k forks source link

Proposal: Have you thought about using monolog as logger? #13702

Closed antonmarin closed 7 years ago

antonmarin commented 7 years ago

Monolog used by many frameworks. Have you thought about using monolog instead own logger implementation?

P.S. I know about yii2-monolog extension. I mean core usage

samdark commented 7 years ago

I'm OK with replacing some implementations with better components. I haven't really compared Monolog to our implementation in detail. What are cons and pros?

antonmarin commented 7 years ago

Pros:

Cons:

samdark commented 7 years ago

Changing interface is possible in 2.1 so PSR-3 could be excluded from the list of cons, I think.

How about performance? Logging is very central application thing so if Monolog is significantly slower, it would be seen immediately.

antonmarin commented 7 years ago

Well, monolog logger is just an observer that throws messages to handlers. So it is closer to yii target then yii logger. I think it is suitable to use same dispatcher with some additions doing this we can achieve same performance and increase count of handlers. Smth like:

samdark commented 7 years ago

Sounds interesting to try to me. @yiisoft/core-developers thoughts?

klimov-paul commented 7 years ago

Support of Monolog is a matter of PSR-3 support. There was an issue about this already - #1676.

klimov-paul commented 7 years ago

Also there is related issue #7555. It actually may happen some extension for Monolog support already exists.

antonmarin commented 7 years ago

As i said earlier, there is extension yii2-monolog. We are talking about core usage and profit of many handlers already implemented

klimov-paul commented 7 years ago

We are talking about core usage and profit of many handlers already implemented

Following this path, inside the core there should be support for PSR-3 compatible logger. Then monolog can be used as a particular one. Including monolog as a a default log processor will create an external dependency, which contradicts #8452.

samdark commented 7 years ago

I think that would do. Overall Yii logging is implemented well so there's no intent dropping it in favor of anything to save maintenance cost.

samdark commented 7 years ago

I'll leave it open since I want to try creating PSR-3 target for our logger.

samdark commented 7 years ago

Here's an extension: https://github.com/samdark/yii2-psr-log-target

samdark commented 7 years ago

For 2.1 we may consider either making out logger PSR-3 compatible or replacing it with Monolog.

antonmarin commented 7 years ago

It is available to make Logger psr-compatible without breaking BC if Yii uses only shortcuts. What you think about it? I can prepare PR

samdark commented 7 years ago

@antonmarin I don't think you can make Yii logger PSR-compatible in 2.0.x because PSR-3 requires absence of non-standard log levels.

antonmarin commented 7 years ago

Users SHOULD NOT use a custom level without knowing for sure the current implementation supports it.

Sounds like recommendation and we can split logger to Logger and Profiler. @samdark what is your opinion about this way?

samdark commented 7 years ago

Right. It's a recommendation. Worth trying then...

klimov-paul commented 7 years ago

PR opened: #14611

klimov-paul commented 7 years ago

Resolved via #14611