package main
import (
"context"
"github.com/gogf/gf/v2/frame/g"
)
func main() {
ctx := context.TODO()
g.Log().Line().Print(ctx, "this is the short file name with its line number")
g.Log().Line(true).Print(ctx, "lone file name with line number")
}
执行后,终端输出结果为:
2019-05-23 09:22:58.141 glog_line.go:8: this is the short file name with its line number
2019-05-23 09:22:58.142 /Users/john/Workspace/Go/GOPATH/src/github.com/gogf/gf/.example/os/glog/glog_line.go:9: lone file name with line number
package main
import (
"context"
"github.com/gogf/gf/v2/frame/g"
)
func PrintLog(ctx context.Context, content string) {
g.Log().Skip(1).Line().Print(ctx, "line number with skip:", content)
g.Log().Line().Print(ctx, "line number without skip:", content)
}
func main() {
ctx := context.TODO()
PrintLog(ctx, "just test")
}
执行后,终端输出结果为:
2019-05-23 19:30:10.984 glog_line2.go:13: line number with skip: just test
2019-05-23 19:30:10.984 glog_line2.go:9: line number without skip: just test