Git Product home page Git Product logo

Comments (11)

phemmer avatar phemmer commented on April 27, 2024 6

I think the default mode shouldn't be debug mode, but rather release mode.

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.
Also, in every app I've ever used, debug mode is off by default, and you turn it on when you want it.

I feel there are 2 appropriate rules from the unix philosophy here:

  • Rule of Least Surprise
    Developers should design programs that build on top of the potential users' expected knowledge; for example, ‘+’ in a calculator program should always mean 'addition'. This rule aims to encourage developers to build intuitive products that are easy to use.
  • Rule of Silence
    Developers should design programs so that they do not print unnecessary output. This rule aims to allow other programs and developers to pick out the information they need from a program's output without having to parse verbosity.

from gin.

manucorporat avatar manucorporat commented on April 27, 2024

Check out the first commit: 809eee8

from gin.

themartorana avatar themartorana commented on April 27, 2024

I may be missing something, but how would I interrogate the current mode in my code?

from gin.

manucorporat avatar manucorporat commented on April 27, 2024

ok, right now there is not a API to interrogate the current mode, you just can change it.
I am ok to add an API, but could you explain an use case for that?

from gin.

themartorana avatar themartorana commented on April 27, 2024

@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.

from gin.

manucorporat avatar manucorporat commented on April 27, 2024

fd2e342

from gin.

themartorana avatar themartorana commented on April 27, 2024

Awesome!

from gin.

roosmaa avatar roosmaa commented on April 27, 2024

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.

from gin.

manucorporat avatar manucorporat commented on April 27, 2024

@roosmaa you are probably right, it's very easy to miss that.
I am going to think about that. thanks!

from gin.

MrGossett avatar MrGossett commented on April 27, 2024

+1 for @phemmer's comment. Default mode should be release mode.

from gin.

ezeql avatar ezeql commented on April 27, 2024

I agree with @roosmaa, @phemmer and @MrGossett.

from gin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.