2023-10-31 23:19:52 +00:00
|
|
|
package aid
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2023-11-01 21:51:14 +00:00
|
|
|
"time"
|
2023-11-09 18:53:19 +00:00
|
|
|
|
|
|
|
"github.com/goccy/go-json"
|
2023-10-31 23:19:52 +00:00
|
|
|
)
|
|
|
|
|
2023-11-02 17:50:52 +00:00
|
|
|
func Print(v ...interface{}) {
|
|
|
|
if Config.Output.Level == "prod" {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Println(v...)
|
|
|
|
}
|
|
|
|
|
2023-10-31 23:19:52 +00:00
|
|
|
func PrintJSON(v interface{}) {
|
2024-01-03 23:49:40 +00:00
|
|
|
if Config.Output.Level == "prod" {
|
2023-11-01 21:51:14 +00:00
|
|
|
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()) {
|
|
|
|
current := time.Now()
|
2023-11-05 02:43:21 +00:00
|
|
|
|
2023-11-01 21:51:14 +00:00
|
|
|
for _, f := range functions {
|
|
|
|
f()
|
|
|
|
}
|
2023-11-05 02:43:21 +00:00
|
|
|
|
|
|
|
if Config.Output.Level == "prod" {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2023-11-01 21:51:14 +00:00
|
|
|
fmt.Println(label + ":", time.Since(current))
|
2023-10-31 23:19:52 +00:00
|
|
|
}
|