feat: set dev-mode into config
This commit is contained in:
parent
d7eba0a5d6
commit
792ee4ebe0
@ -20,6 +20,8 @@
|
|||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
# SOFTWARE.
|
# SOFTWARE.
|
||||||
|
|
||||||
|
dev-mode: true
|
||||||
|
|
||||||
addr: :8080
|
addr: :8080
|
||||||
|
|
||||||
db:
|
db:
|
||||||
@ -40,7 +42,6 @@ db:
|
|||||||
|
|
||||||
log:
|
log:
|
||||||
level: debug
|
level: debug
|
||||||
development: true
|
|
||||||
disalbe-caller: false
|
disalbe-caller: false
|
||||||
disable-stacktrace: false
|
disable-stacktrace: false
|
||||||
# console or json
|
# console or json
|
||||||
|
@ -75,7 +75,7 @@ func initConfig() {
|
|||||||
func logOptions() *log.Options {
|
func logOptions() *log.Options {
|
||||||
return &log.Options{
|
return &log.Options{
|
||||||
Level: viper.GetString("log.level"),
|
Level: viper.GetString("log.level"),
|
||||||
Development: viper.GetBool("log.development"),
|
Development: viper.GetBool("dev-mode"),
|
||||||
DisableCaller: viper.GetBool("log.disable-caller"),
|
DisableCaller: viper.GetBool("log.disable-caller"),
|
||||||
DisableStacktrace: viper.GetBool("log.disable-stacktrace"),
|
DisableStacktrace: viper.GetBool("log.disable-stacktrace"),
|
||||||
Format: viper.GetString("log.format"),
|
Format: viper.GetString("log.format"),
|
||||||
|
@ -102,6 +102,13 @@ func run() error {
|
|||||||
log.InfoLog(string(settings))
|
log.InfoLog(string(settings))
|
||||||
log.InfoLog(viper.GetString("db.username"))
|
log.InfoLog(viper.GetString("db.username"))
|
||||||
|
|
||||||
|
isDev := viper.GetBool("dev-mode")
|
||||||
|
if isDev {
|
||||||
|
gin.SetMode(gin.DebugMode)
|
||||||
|
} else {
|
||||||
|
gin.SetMode(gin.ReleaseMode)
|
||||||
|
}
|
||||||
|
|
||||||
r := gin.Default()
|
r := gin.Default()
|
||||||
|
|
||||||
r.GET("/", func(ctx *gin.Context) {
|
r.GET("/", func(ctx *gin.Context) {
|
||||||
|
Loading…
Reference in New Issue
Block a user