mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 11:39:17 +00:00
more golint cleanup
This commit is contained in:
parent
ef8f71d403
commit
d0145bb579
@ -10,12 +10,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var hideLog bool = false
|
//Logger prints endpoint details
|
||||||
|
|
||||||
func SetHideLog(hide bool) {
|
|
||||||
hideLog = hide
|
|
||||||
}
|
|
||||||
|
|
||||||
func Logger(inner http.Handler, name string) http.Handler {
|
func Logger(inner http.Handler, name string) http.Handler {
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
@ -32,8 +27,9 @@ func Logger(inner http.Handler, name string) http.Handler {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//ErrResponse prints detailed error event and sets response
|
||||||
func ErrResponse(w http.ResponseWriter, code int, err error) {
|
func ErrResponse(w http.ResponseWriter, code int, err error) {
|
||||||
if !hideLog && err != nil {
|
if err != nil {
|
||||||
_, file, line, _ := runtime.Caller(1)
|
_, file, line, _ := runtime.Caller(1)
|
||||||
p, _ := os.Getwd()
|
p, _ := os.Getwd()
|
||||||
log.Printf("%s:%d %s", strings.TrimPrefix(file, p), line, err.Error())
|
log.Printf("%s:%d %s", strings.TrimPrefix(file, p), line, err.Error())
|
||||||
@ -41,22 +37,23 @@ func ErrResponse(w http.ResponseWriter, code int, err error) {
|
|||||||
w.WriteHeader(code)
|
w.WriteHeader(code)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//ErrMsg prints detailed error event
|
||||||
func ErrMsg(err error) {
|
func ErrMsg(err error) {
|
||||||
if !hideLog && err != nil {
|
if err != nil {
|
||||||
_, file, line, _ := runtime.Caller(1)
|
_, file, line, _ := runtime.Caller(1)
|
||||||
p, _ := os.Getwd()
|
p, _ := os.Getwd()
|
||||||
log.Printf("%s:%d %s", strings.TrimPrefix(file, p), line, err.Error())
|
log.Printf("%s:%d %s", strings.TrimPrefix(file, p), line, err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//LogMsg prints detailed error string
|
||||||
func LogMsg(msg string) {
|
func LogMsg(msg string) {
|
||||||
if !hideLog {
|
|
||||||
_, file, line, _ := runtime.Caller(1)
|
_, file, line, _ := runtime.Caller(1)
|
||||||
p, _ := os.Getwd()
|
p, _ := os.Getwd()
|
||||||
log.Printf("%s:%d %s", strings.TrimPrefix(file, p), line, msg)
|
log.Printf("%s:%d %s", strings.TrimPrefix(file, p), line, msg)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
//PrintMsg prints debug message
|
||||||
func PrintMsg(obj interface{}) {
|
func PrintMsg(obj interface{}) {
|
||||||
pretty.Println(obj)
|
pretty.Println(obj)
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ import (
|
|||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
|
|
||||||
// SetHideLog(true)
|
|
||||||
SetKeySize(2048)
|
SetKeySize(2048)
|
||||||
os.Remove("databag.db")
|
os.Remove("databag.db")
|
||||||
os.RemoveAll("testdata")
|
os.RemoveAll("testdata")
|
||||||
|
Loading…
Reference in New Issue
Block a user