本文整理汇总了Golang中github.com/astaxie/beego.SetLogger函数的典型用法代码示例。如果您正苦于以下问题:Golang SetLogger函数的具体用法?Golang SetLogger怎么用?Golang SetLogger使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SetLogger函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: init
func init() {
//获取当天时间
now := time.Now().Format("2006-01-02")
file, err := os.OpenFile("/Users/mac/mygo/src/blog/log/"+now+".log", os.O_RDWR|os.O_APPEND, 0644)
if err != nil {
fd, err := os.Create("/Users/mac/mygo/src/blog/log/" + now + ".log")
if err != nil {
beego.Critical("openfile beepkg.log:", err)
return
}
lg := log.New(fd, "", log.Ldate|log.Ltime)
beego.SetLogger(lg)
}
lg := log.New(file, "", log.Ldate|log.Ltime)
beego.SetLogger(lg)
}
开发者ID:hobartcui,项目名称:blogs,代码行数:16,代码来源:log.go
示例2: init
func init() {
/* 로그기록 */
//NewLogger(10000)
beego.SetLogger("file", `{"filename":"server.log"}`)
/* 데이타베이스 드라이브 설정 */
orm.RegisterDriver("mysql", orm.DR_MySQL)
orm.RegisterDataBase("default", "mysql", "root:[email protected]/cluber?charset=utf8&loc=Asia%2FSeoul")
/* 데이타베이스 테이블 등록 */
orm.RegisterModel(new(models.User))
orm.RegisterModel(new(models.Log))
orm.RegisterModel(new(models.Contents))
// 사용 데이타베이스
name := "default"
// 서버 시작시 테이블 재생성
force := false
// SQL 로그 확인
verbose := true
// 데이타베이스를 동기화 하고 에러 발생시 err 에 에러내용 입력
err := orm.RunSyncdb(name, force, verbose)
if err != nil {
fmt.Println(err)
}
}
开发者ID:GeoLyu,项目名称:test,代码行数:27,代码来源:main.go
示例3: init
func init() {
// Try to have highest performance.
runtime.GOMAXPROCS(runtime.NumCPU())
// Set application log level.
beego.SetLevel(beego.LevelTrace)
// Initialize log file.
os.Mkdir("./log", os.ModePerm)
// Compute log file name as format '<year>-<month>-<day>.txt', eg.'2013-5-6.txt'.
logName := fmt.Sprintf("./log/%d-%d-%d.txt", time.Now().Year(), time.Now().Month(), time.Now().Day())
// Open or create log file.
var fl *os.File
var err error
if utils.IsExist(logName) {
fl, err = os.OpenFile(logName, os.O_RDWR|os.O_APPEND, 0644)
} else {
fl, err = os.Create(logName)
}
if err != nil {
beego.Trace("Failed to init log file ->", err)
return
}
beego.Info("Go Walker", VERSION)
beego.SetLogger(log.New(fl, "", log.Ldate|log.Ltime))
}
开发者ID:richardjoo,项目名称:gowalker,代码行数:26,代码来源:gowalker.go
示例4: init
func init() {
beego.Router("/", &controllers.RootController{})
beego.Router("/login/?:dest", &controllers.LoginController{})
beego.Router("/logout/?:dest", &controllers.LogoutController{})
beego.Router("/signup/?:dest", &controllers.SignupController{})
beego.Router("/live-editor/", &controllers.LiveEditorController{})
beego.Router("/graphics-animation/", &controllers.GraphicsController{})
beego.Router("/external/:file", &controllers.LiveEditorController{})
beego.SetStaticPath("/build", "bootstrap/live-editor/build")
var FilterUser = func(ctx *context.Context) {
_, ok := ctx.Input.Session("uid").(int)
if !ok {
ctx.Redirect(302, "/login")
}
}
beego.InsertFilter("/user/:id([0-9]+)", beego.BeforeRouter, FilterUser)
beego.ErrorController(&controllers.ErrorController{})
beego.SetLogger("file", `{"filename":"log/spielplatz.log"}`)
loadLanguages()
}
开发者ID:lafisrap,项目名称:Computer-Spielplatz,代码行数:25,代码来源:router.go
示例5: main
func main() {
initDb()
beego.InsertFilter("/*", beego.BeforeRouter, FilterUser)
wbconf.LoadCategory()
beego.SetLogger("file", `{"filename":"logs/running.log", "level":6 }`)
beego.Run()
}
开发者ID:zixinjian,项目名称:webo_dev,代码行数:8,代码来源:main.go
示例6: main
func main() {
beego.SetLevel(beego.LevelInformational)
beego.SetLogFuncCall(true)
beego.SetLogger("file", `{"filename":"logs/test.log"}`)
orm.Debug = true
orm.RunSyncdb("default", false, true)
beego.Run()
}
开发者ID:lcbyz,项目名称:Go,代码行数:8,代码来源:main.go
示例7: main
func main() {
beego.SetLogger("file", `{"filename":"logs/output.log"}`)
beego.SetLogFuncCall(true)
controllers.DIYFunc()
beego.ErrorController(&controllers.ErrorController{})
beego.Run()
}
开发者ID:Hevi-Ye,项目名称:mini-ERP,代码行数:9,代码来源:main.go
示例8: Initialize
func Initialize(c conf.Logger) (err error) {
switch c.Dist {
case "file":
if c.File.Minutes <= 0 {
return
}
loggerErrChan := make(chan error)
now := time.Now()
m := now.Minute()
i := (c.File.Minutes-(m-(m/c.File.Minutes*c.File.Minutes)))*60 - now.Second()
go func(i int) {
//Pre declaration need this for excluding redeclare any time variables in unlimited loop
var dir, s string
var err error
var now time.Time
for {
now = time.Now()
dir = c.File.Folder + fmt.Sprintf("%02d_%02d_%02d", now.Day(), now.Month(), now.Year())
err = os.MkdirAll(dir, os.ModePerm)
if err == nil {
s = dir + "/" + fmt.Sprintf("%02d_%02d", now.Hour(), now.Minute()/c.File.Minutes*c.File.Minutes)
if c.File.Ext != "" {
s += "." + c.File.Ext
}
err = beego.SetLogger("file", `{"filename":"`+s+`"}`)
}
if err != nil {
loggerErrChan <- err
}
time.Sleep(time.Millisecond * 1000 * time.Duration(i))
i = c.File.Minutes * 60
}
}(i)
go func() {
for {
beego.Error(<-loggerErrChan)
}
}()
}
return
}
开发者ID:grr89,项目名称:hrkb,代码行数:57,代码来源:logger.go
示例9: main
func main() {
//beego.EnableAdmin = true
//beego.AdminHttpPort = 3001
beego.SetLogger("console", "")
beego.Router("/", &MainController{})
if beego.AppConfig.String("imagepath") != imagePath {
imagePath = beego.AppConfig.String("imagepath")
}
beego.Run()
}
开发者ID:mehulsbhatt,项目名称:tesseractproxy,代码行数:10,代码来源:main.go
示例10: main
func main() {
beego.SetLogger("file", `{"filename":"logs/beego_bootstrap_api.log"}`)
orm.RunCommand()
if beego.BConfig.RunMode == "dev" {
orm.Debug = true
file, _ := os.OpenFile("logs/orm.log", os.O_APPEND|os.O_WRONLY, 0600)
orm.DebugLog = orm.NewLog(file)
}
beego.Run()
}
开发者ID:Piasy,项目名称:BeegoTDDBootStrap,代码行数:10,代码来源:main.go
示例11: main
func main() {
orm.Debug = true
//第二个参数表示数据表是不是每次启动的时候删除再重建,第三个参数是打印相关信息
orm.RunSyncdb("default", false, true)
fmt.Println("这是一个测试代码")
beego.SetLogger("file", `{"filename":"logs/test.log"}`)
beego.Run()
}
开发者ID:Hevi-Ye,项目名称:blog,代码行数:10,代码来源:main.go
示例12: main
func main() {
//initCache()
orm.Debug, _ = beego.AppConfig.Bool("orm_debug")
//logFile := beego.AppConfig.String("log_file")
beego.SetLogger("file", `{"filename":"logs/o2oapi.log"}`)
beego.SetLogFuncCall(true)
beego.Run()
}
开发者ID:wfnuser,项目名称:o2oadmin,代码行数:11,代码来源:main.go
示例13: init
func init() {
showNumberLine, _ := beego.AppConfig.Bool("logger.numberLine")
levelString := beego.AppConfig.String("logger.level")
logModels := beego.AppConfig.Strings("logger.logger")
for _, logModel := range logModels {
if logModel == "console" {
beego.SetLogger("console", "")
}
if logModel == "file" {
filename := beego.AppConfig.String("logger.filename")
config := fmt.Sprintf(`{"filename":"%s","maxdays":30}`, filename)
beego.SetLogger("file", config)
}
}
if showNumberLine {
beego.SetLogFuncCall(showNumberLine)
}
level, _ := Levelify(levelString)
beego.SetLevel(level)
}
开发者ID:alex8023,项目名称:citycloud.cf-deploy-ui,代码行数:20,代码来源:logger.go
示例14: InitLog
func InitLog() {
if beego.BConfig.RunMode == "dev" {
beego.Info("initiating log")
}
logconf, err := gofile.IoUtilReadFile(filepath.Join(beego.AppPath, "conf", "log.json"))
if err != nil {
panic(err)
} else {
beego.SetLogger("file", string(logconf))
}
}
开发者ID:sillydong,项目名称:goczd,代码行数:12,代码来源:init.go
示例15: main
func main() {
if beego.RunMode != "dev" {
beego.BeeLogger.SetLevel(logs.LevelWarning)
beego.BeeLogger.DelLogger("console")
beego.SetLogger("file", `{"filename":"logs/app.log"}`)
} else {
beego.BeeLogger.SetLevel(logs.LevelDebug)
}
beego.Run()
}
开发者ID:gitwillsky,项目名称:btsearcher_web,代码行数:12,代码来源:btweb.go
示例16: init
func init() {
////// 初始化日志
beego.SetLogger("file", `{"filename":"go_dg.log"}`)
iniconf, err := config.NewConfig("ini", "config.conf")
if err != nil {
beego.Error("init config error", err)
beego.BeeLogger.Flush()
panic("init failed")
}
Config_Data_URL = iniconf.String("data_url")
Config_PRS_URL = iniconf.String("prs_url")
}
开发者ID:ilahsa,项目名称:go,代码行数:13,代码来源:main.go
示例17: main
func main() {
beego.SessionOn = true
beego.ErrorController(&controllers.ErrorController{})
beego.AddFuncMap("i18n", i18n.Tr)
beego.EnableAdmin = true // Port 8088
beego.SetLogger("file", `{"filename":"logs/juna.log"}`)
beego.SetLevel(beego.LevelInformational)
beego.SetLogFuncCall(true)
beego.AddFuncMap("news", news)
beego.Run()
}
开发者ID:shenyp09,项目名称:juna,代码行数:14,代码来源:main.go
示例18: main
func main() {
models.InitDb()
beego.SessionOn = true
beego.SetLogger("file", `{"filename":"`+common.Webconfig.LogFile+`"}`)
beego.SetLevel(beego.LevelInformational)
beego.SetLogFuncCall(true)
beego.Info("begin setting router")
beego.Router("/", &routers.HomeRouter{})
beego.Router(`/page/:page([\d]+)`, &routers.HomeRouter{})
beego.Router(`/article/:article([\w-]+)`, &routers.ArticleRouter{})
beego.Router(`/tag/:tag([\S]+)/:page([\d]+)`, &routers.TagRouter{})
beego.Router(`/tag/:tag([\S]+)`, &routers.TagRouter{})
beego.Router(`/node/:node([\S]+)/:page([\d]+)`, &routers.NodeRouter{})
beego.Router(`/node/:node([\S]+)`, &routers.NodeRouter{})
beego.Router(`/category/:category([\S]+)/:page([\d]+)`, &routers.CategoryRouter{})
beego.Router(`/category/:category([\S]+)`, &routers.CategoryRouter{})
beego.Router("/subscribe", &routers.SubscribeRouter{})
beego.Router(`/subscribe/:uid([\S]+)`, &routers.SubscribeRouter{})
beego.Router(`/desubscribe/:uid([\S]+)`, &routers.SubscribeRouter{})
beego.Router("/root", &root.RootMainRouter{})
beego.Router("/root/category", &root.RootCategoryRouter{})
beego.Router("/root/node", &root.RootNodeRouter{})
beego.Router("/root/tag", &root.RootTagRouter{})
beego.Router(`/root/article`, &root.RootArticleRouter{})
//beego.Router(`/root/article/:opt([a-z]+)`, &root.RootArticleRouter{})
beego.Router(`/root/article/:page([\d]+)`, &root.RootArticleRouter{})
beego.Router("/root/upload", &root.RootUploadRouter{})
beego.Router("/root/login", &root.LoginRouter{})
beego.Router("/root/loginout", &root.LoginOutRouter{})
beego.Router(`/prompt/:code([\w]+)`, &routers.PromptRouter{})
beego.Info("starting server")
beego.Run()
}
开发者ID:royburns,项目名称:MessageBlog,代码行数:49,代码来源:blog.go
示例19: init
func init() {
GlobalSessions, _ = session.NewManager("memory", `{
"cookieName":"lte_securityid",
"enableSetCookie,omitempty": true,
"gclifetime":3600,
"maxLifetime": 3600,
"secure": true,
"sessionIDHashFunc": "sha1",
"sessionIDHashKey": "",
"cookieLifeTime": 3600,
"providerConfig": ""}`)
go GlobalSessions.GC()
beego.SetLogger("file", `{"filename":"logs/server.log"}`)
beego.SetLevel(beego.LevelDebug)
}
开发者ID:tcdog001,项目名称:szm_lss,代码行数:15,代码来源:main.go
示例20: initialize
// We have to call a initialize function manully
// because we use `bee bale` to pack static resources
// and we cannot make sure that which init() execute first.
func initialize() {
setting.LoadConfig()
//set logger
if setting.IsProMode {
beego.SetLogger("file", `{"filename":"logs/prod.log"}`)
beego.SetLevel(beego.LevelInformational)
beego.BeeLogger.DelLogger("console")
} else {
beego.SetLogger("file", `{"filename":"logs/dev.log"}`)
beego.SetLevel(beego.LevelDebug)
beego.BeeLogger.SetLogger("console", "")
}
beego.SetLogFuncCall(true)
setting.SocialAuth = social.NewSocial("/login/", auth.SocialAuther)
setting.SocialAuth.ConnectSuccessURL = "/settings/profile"
setting.SocialAuth.ConnectFailedURL = "/settings/profile"
setting.SocialAuth.ConnectRegisterURL = "/register/connect"
setting.SocialAuth.LoginURL = "/login"
//Qiniu
ACCESS_KEY = setting.QiniuAccessKey
SECRET_KEY = setting.QiniuSecurityKey
}
开发者ID:varding,项目名称:wetalk,代码行数:27,代码来源:wetalk.go
注:本文中的github.com/astaxie/beego.SetLogger函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论