1 Star 0 Fork 0

api-go/revel-cmd

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
log.go 1.25 KB
一键复制 编辑 原始数据 按行查看 历史
NotZippy 提交于 2018-09-27 21:08 . Enhancements to Revel command
package utils
import (
"fmt"
"github.com/revel/cmd/logger"
"github.com/revel/config"
"os"
"strings"
)
var Logger = logger.New()
func InitLogger(basePath string, logLevel logger.LogLevel) {
newContext := config.NewContext()
if logLevel == logger.LvlDebug {
newContext.SetOption("log.debug.output", "stdout")
println("Debug on")
} else {
newContext.SetOption("log.debug.output", "off")
}
if logLevel >= logger.LvlInfo {
newContext.SetOption("log.info.output", "stdout")
} else {
newContext.SetOption("log.inf.output", "off")
}
newContext.SetOption("log.warn.output", "stderr")
newContext.SetOption("log.error.output", "stderr")
newContext.SetOption("log.crit.output", "stderr")
Logger.SetHandler(logger.InitializeFromConfig(basePath, newContext))
}
// This function is to throw a panic that may be caught by the packger so it can perform the needed
// imports
func Retry(format string, args ...interface{}) {
// Ensure the user's command prompt starts on the next line.
if !strings.HasSuffix(format, "\n") {
format += "\n"
}
fmt.Fprintf(os.Stderr, format, args...)
panic(format) // Panic instead of os.Exit so that deferred will run.
}
type LoggedError struct{ error }
func NewLoggedError(err error) *LoggedError {
return &LoggedError{err}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/netscript/revel-cmd.git
git@gitee.com:netscript/revel-cmd.git
netscript
revel-cmd
revel-cmd
v0.20.2

搜索帮助

0d507c66 1850385 C8b1a773 1850385