-
Notifications
You must be signed in to change notification settings - Fork 52
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
Add a debug mode #11
Comments
I like the idea. I wonder if there's prior art in including debug code in JS that is elided for production builds? Even if it's included in the production build it probably wouldn't add that much weight. |
The situation of logger has always been annoying. You can either decide to drop the logs altogether by doing dead-code elimination (except that most of the time you rely on tools for that), Or, Shameful plug: https://github.com/straw-hat-team/logger You can create a logger instance in I added https://github.com/straw-hat-team/logger/blob/6636837f12f31949467e722d653f9d658aef2189/src/log-handler.ts#L41 in order to check to enable in production the logs if some developer is having trouble, you would do in the console: globalThis.STRAW_HAT_GLOBALS = {
logger: {
level: 5 // Error
}
} Or, expect an interface of the logger https://github.com/straw-hat-team/logger/blob/dcfbe92c57ba26ee7d342b2c044234dcfcc9a7d3/src/types.ts#L7, and pass a noop-logger https://github.com/straw-hat-team/logger/blob/f3b5533e75741a0451053418e92e17123eca52bf/src/noop-logger.ts#L3 The package is small enough so may be an option (maybe they are some trick to make it even smaller, not sure, PR welcome) |
@yordis Thanks, the project looks neat! Do you really need 8 log levels? :) I've always been happy with just The script here is so small that I think all we really need is a single flag: debug either on of off. |
@ukutaht I am following Elixir steps on this one ;) https://github.com/elixir-lang/elixir/releases/tag/v1.11.0
I am rather in line with Syslog and obviously ignore some of the levels on the web, but I don't see an issue with alignment on it Also, you could use it in the backend if you would like to, the package is not bound to the browser environment. |
Right, that is what I thought after I saw the compiled version LOL, but as I said, if I can pass my own logger (which is why you could take an interface), then it doesn't matter much. Maybe create a tiny interface instead of 8 levels, from my perspective, it all depends of the implementation of the logger. 8 function declarations are like bytes that wouldn't matter that much unless you definitely want to save every single byte, then, just reduce the object to a function type Logger = ()=> void |
Oh thanks for that, I didn't even know there were so many levels in Elixir :)
Yeah that seems nice and simple, I like that. |
Inspired from the Google Analytics debugging, it would be nice to see what events are being sent.
Detailed Description
Basically, add a
console.debug
statement insendEvent
that would output the event name and all the parameters it's sending to Plausible.Context
This would be similar to going to the browser network tab, filtering to your Plausible domain, and going through all of the request data. Just easier. At the same time, I can see this being just gravy and adding to the bundle size.
Possible Implementation
Simply adding an option to
PlausibleInitOptions
and anif
statement tosendEvent
.The text was updated successfully, but these errors were encountered: