good morning!!!!

Skip to content
Snippets Groups Projects
Commit f10e0a82 authored by José Carlos Nieto's avatar José Carlos Nieto
Browse files

Adding "debug" build tag.

parent e9be46b6
Branches
Tags
No related merge requests found
// +build !debug
package db
var Debug = false
// +build debug
package db
var Debug = true
......@@ -30,6 +30,12 @@ import (
"upper.io/db"
)
func init() {
if os.Getenv(db.EnvEnableDebug) != "" {
db.Debug = true
}
}
// Debug is used for printing SQL queries and arguments.
type Debug struct {
SQL string
......@@ -63,15 +69,8 @@ func (d *Debug) Print() {
log.Printf("\n\t%s\n\n", strings.Join(s, "\n\t"))
}
func IsDebugEnabled() bool {
if os.Getenv(db.EnvEnableDebug) != "" {
return true
}
return false
}
func Log(query string, args []interface{}, err error, start int64, end int64) {
if IsDebugEnabled() {
if db.Debug {
d := Debug{query, args, err, start, end}
d.Print()
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment