Seldaek / monolog

Sends your logs to files, sockets, inboxes, databases and various web services
https://seldaek.github.io/monolog/
MIT License
21.04k stars 1.9k forks source link

Allow the user to define a custom mode when `fopen`-ing a log file #1913

Closed phrfpeixoto closed 1 week ago

phrfpeixoto commented 2 months ago

I've included changes to both allow custom fopen modes, as well as change the visibility of the helper functions on this class. I've made them final to keep the "do not touch" aspect, while still allowing subclasses to use them.

stof commented 2 months ago

with the new argument, do you actually need to extend the class and call those protected functions ? If yes, why ? If no, I would not change their visibility as making them protected means they become part of the API that is covered by semver (and so they cannot be refactored to change their signature or be removed if the code does not need them anymore)

phrfpeixoto commented 2 months ago

It doesn't. I've added that specifically to bring that discussion:

Whichever change is less disruptive for the project is OK for me.

IMO, it's likely that you'll want to change the class constructor's signature (other than those helper functions) as time passes, so if you're worried about semver, it would be better to expose those helper methods (they are final, after all).

phrfpeixoto commented 2 months ago

@stof Let me know what changes you would prefer.

Seldaek commented 1 month ago

What's the use case here? Why is 'a' not good enough? Just curious/trying to understand. But in general I'd say given the edge case-ness here, I feel like a setter might be more appropriate than a constructor arg.

phrfpeixoto commented 2 weeks ago

@Seldaek The use case is having the file overwritten, instead of appended.

Seldaek commented 1 week ago

Thanks