2023-10-31 23:19:52 +00:00
|
|
|
package aid
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
2023-11-01 21:51:14 +00:00
|
|
|
"time"
|
2023-10-31 23:19:52 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func PrintJSON(v interface{}) {
|
2023-11-01 21:51:14 +00:00
|
|
|
if Config.Output.Level == "prod" || Config.Output.Level == "time" {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2023-10-31 23:19:52 +00:00
|
|
|
json1, err := json.MarshalIndent(v, "", " ")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
fmt.Println(string(json1))
|
2023-11-01 21:51:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func PrintTime(label string, functions ...func()) {
|
|
|
|
if Config.Output.Level == "prod" {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
current := time.Now()
|
|
|
|
for _, f := range functions {
|
|
|
|
f()
|
|
|
|
}
|
|
|
|
fmt.Println(label + ":", time.Since(current))
|
2023-10-31 23:19:52 +00:00
|
|
|
}
|