github.com/gogf/gf@v1.16.9/internal/utils/utils_debug.go (about) 1 // Copyright GoFrame Author(https://goframe.org). All Rights Reserved. 2 // 3 // This Source Code Form is subject to the terms of the MIT License. 4 // If a copy of the MIT was not distributed with this file, 5 // You can obtain one at https://github.com/gogf/gf. 6 7 package utils 8 9 import ( 10 "github.com/gogf/gf/internal/command" 11 ) 12 13 const ( 14 commandEnvKeyForDebugKey = "gf.debug" // Debug key for checking if in debug mode. 15 StackFilterKeyForGoFrame = "github.com/gogf/gf@" // Stack filtering key for all GoFrame module paths. 16 ) 17 18 var ( 19 // isDebugEnabled marks whether GoFrame debug mode is enabled. 20 isDebugEnabled = false 21 ) 22 23 func init() { 24 // Debugging configured. 25 value := command.GetOptWithEnv(commandEnvKeyForDebugKey) 26 if value == "" || value == "0" || value == "false" { 27 isDebugEnabled = false 28 } else { 29 isDebugEnabled = true 30 } 31 } 32 33 // IsDebugEnabled checks and returns whether debug mode is enabled. 34 // The debug mode is enabled when command argument "gf.debug" or environment "GF_DEBUG" is passed. 35 func IsDebugEnabled() bool { 36 return isDebugEnabled 37 }