maksverver / astral-codex-eleven

A Chrome browser extension to speed up loading of posts on https://www.astralcodexten.com/ by replacing the comments widget.
MIT License
4 stars 2 forks source link

Add logging utilities #18

Open Pycea opened 4 months ago

Pycea commented 4 months ago

Create a class to simplify logging a little.

Add a utility for timing, and increase performance timing logs.

maksverver commented 4 months ago

This is another change where I'm not sure that the pros outweigh the cons. I want to keep the code small and simple to review, and avoid frameworks, libraries or generalizations that don't pull their weight.

The logging change doesn't simplify code meaningfully; it eliminates the LOG_TAG parameter but at the expense of introducing a new interface. I see the Logger class has a way to tune the log level, but this sounds like YAGNI: without an easy mechanism to change the log level it won't be changed, and I don't see why we'd need it in the first place. If it's about filtering out unnecessary info: you can do that in the browser console. If it's about avoiding performance overhead: ideally you'd want a mechanism to disable logging at the callsite instead. Either way, I would rather aim for keeping logging to a reasonably small amount (currently, the number of log items written is a small constant per user action).

Similar for the timer: I think we should aim to minimize the number of places where we do timing rather than introduce complex timing functionality. I'm not opposed to adding a timer to processComments() as you did, but I don't see why you can't just call performance.now() directly.