-
Notifications
You must be signed in to change notification settings - Fork 8k
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
Development mode #96
Comments
Check out the first commit: 809eee8 |
I may be missing something, but how would I interrogate the current mode in my code? |
ok, right now there is not a API to interrogate the current mode, you just can change it. |
@manucorporat our use-case is of course likely specific to our own needs, but they exist in the level of logging (which I realize can be pushed off to log configuration, but marrying the two makes sense to me) and for us, attaching additional debug information to a returning JSON packet across our API. Currently we have a single middleware that wraps up all returning responses from handlers into consistent response packets, interrogating errors and return codes for logging and reporting purposes, and attaching any additional information to a packet that is "global" if you will. Being able to make packets lean for production and information-rich at debug/testing time (think staging/development servers) makes sense in our case. |
Awesome! |
I wanted to create a new issue, but it seems more appropriate to comment here. I think the default mode shouldn't be debug mode, but rather release mode. Currently the mode switching is fairly well hidden and it's very easy to miss. Deploying the app without being aware of this means that the app is deployed in default=debug mode. This is fairly bad. Instead of defaulting to debug mode, I suggest displaying a hint about it instead when Gin is starting up. That way developers will discover it and update their environment with the appropriate variable and in production it's only taking up 1 line of log space. |
@roosmaa you are probably right, it's very easy to miss that. |
I second this. I find the debug output extremely annoying. And it's more annoying having to go and turn this off in every single package that imports gin, otherwise your test log is spammed with warning messages and other output (the warning alone is 4 lines long). When you deploy a gin app, the defaults should be that the app runs with minimal configuration. I feel there are 2 appropriate rules from the unix philosophy here:
|
+1 for @phemmer's comment. Default mode should be release mode. |
I agree with @roosmaa, @phemmer and @MrGossett. |
IDEAS
API
GIN_MODE
that is loaded at init time.Any call to this method would replace the default option.
Log example:
The text was updated successfully, but these errors were encountered: