1 Star 0 Fork 0

Wsage/go-framework

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
run_default.go 945 Bytes
一键复制 编辑 原始数据 按行查看 历史
Wsage 提交于 2022-04-06 09:56 . optimize log
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()
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/scottq/go-framework.git
git@gitee.com:scottq/go-framework.git
scottq
go-framework
go-framework
v1.1.39

搜索帮助

Dd8185d8 1850385 E526c682 1850385