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

question(log): remove setup() and destroy() from BaseHandler? #4391

Open
timreichen opened this issue Feb 25, 2024 · 8 comments
Open

question(log): remove setup() and destroy() from BaseHandler? #4391

timreichen opened this issue Feb 25, 2024 · 8 comments
Labels
feedback welcome We want community's feedback on this issue or PR

Comments

@timreichen
Copy link
Contributor

Is your feature request related to a problem? Please describe.

BaseHandler.setup() and BaseHandler.destroy() seem kinda odd as methods for BaseHandler, especially their names.
They do not have a purpose in the BaseHandler itself, except destroy() being called on [Symbol.dispose].

Describe the solution you'd like

I think BaseHandler should remove setup() and destroy(), FileHandler should have methods called open() and close() instead of setup() and destroy() as that describes better what is happening inside the method.
[Symbol.dispose] should be implemented in FileHandler to call close(). RotatingFileHandler would inherit from FileHandler as it does now and could be overridden as needed.

Describe alternatives you've considered

Leave as is.

@iuioiua
Copy link
Collaborator

iuioiua commented Mar 3, 2024

+1

@iuioiua iuioiua added the feedback welcome We want community's feedback on this issue or PR label Mar 3, 2024
@kt3k
Copy link
Member

kt3k commented Mar 4, 2024

-1 to this. Doesn't sound like appropriate reasons for doing breaking changes.

BaseHandler.setup() and BaseHandler.destroy() seem kinda odd as methods for BaseHandler, especially their names.

We shouldn't do breaking changes based on just preferences/tastes.

Breaking changes like these breaks the trust to the standard library in my view.

@timreichen
Copy link
Contributor Author

timreichen commented Mar 4, 2024

-1 to this. Doesn't sound like appropriate reasons for doing breaking changes.

BaseHandler.setup() and BaseHandler.destroy() seem kinda odd as methods for BaseHandler, especially their names.

We shouldn't do breaking changes based on just preferences/tastes.

It is not only about taste, web APIs give some guidance for naming methods and properties. We should orient ourselves towards that. For example dispose() would be better than destroy() because Symbol.dispose exists.

But in this particular case BaseHandler.setup() and BaseHandler.destroy() are empty methods and callbacks (similar to customElements connectedCallback and disconnectedCallback()) for subclasses like FileHandler.
These get called in setup(). But FileHandler.open() can be called manually or inside FileHandler.handle(), if the file is not open yet. Similarly, FileHandler.close() can be called manually and is called on the unload event.

@iuioiua
Copy link
Collaborator

iuioiua commented Mar 5, 2024

To be clear, I'm +1 for removing BaseHandler.setup() and BaseHandler. destroy(), as they're empty methods solely there to be overwritten. IMO that doesn't justify their existence.

Renaming them to .open() and .close() makes more sense than their current names. However, I don't find their current names completely misleading, so my opinion isn't too strong.

@kt3k
Copy link
Member

kt3k commented Mar 5, 2024

as they're empty methods solely there to be overwritten. IMO that doesn't justify their existence.

This seems suggesting removing all of setup and destroy methods in BaseHandler ConsoleHandler FileHandler and RotatingFileHandler (according to #4435). They are not empty methods for FileHandler and RotatingFileHandler.

@iuioiua
Copy link
Collaborator

iuioiua commented Mar 5, 2024

I'm only fully in favour of removing the BaseHandler methods. Please see my latest comment on that PR.

@kt3k
Copy link
Member

kt3k commented Mar 5, 2024

ConsoleHandler doesn't implement setup and destroy, instead inherits them from BaseHandler. I don't think it makes sense to remove them from BaseHandler. (All handlers are supposed to implement setup and destory ref.

handler.setup();

@iuioiua
Copy link
Collaborator

iuioiua commented Mar 6, 2024

Then I think we should also remove ConsoleHandler.setup() and ConsoleHandler.destroy(). Reworking setup() for these changes shouldn't be hard. I think these changes lead to a design that makes more logical sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feedback welcome We want community's feedback on this issue or PR
Projects
None yet
Development

No branches or pull requests

3 participants