代码拉取完成,页面将自动刷新
package main
import (
"fmt"
v1config "gitee.com/scottq/go-framework/src/v1/config"
v1http "gitee.com/scottq/go-framework/src/v1/httpserver"
v1log "gitee.com/scottq/go-framework/src/v1/log"
"os"
"path/filepath"
"time"
)
func TestLog(logger v1log.ILog) {
logger.Info("this is INFO")
logger.Debug("this is DEBUG")
logger.Warn("this is WARN")
logger.Error("this is ERROR")
logger.Fatal("this is FATAL")
}
func main() {
c := &v1config.LogConfig{
LogPath: fmt.Sprintf("../runtime/logs/%s.log", filepath.Base(os.Args[0])),
LogSyncStdOut: true,
}
logger := v1log.NewDefaultLogger("example", c)
logger.Info("hello world")
TestLog(logger)
//
httpServer, err := v1http.NewHttpServer("exampleHttpServer", ":8080")
if err != nil {
logger.Error("run http server error:%s" + err.Error())
panic(err)
}
httpServer.AddLogger(logger)
go func() {
time.Sleep(time.Second * 5)
httpServer.Stop()
}()
httpServer.Run()
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。