• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang beego.SetLevel函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/astaxie/beego.SetLevel函数的典型用法代码示例。如果您正苦于以下问题:Golang SetLevel函数的具体用法?Golang SetLevel怎么用?Golang SetLevel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了SetLevel函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: init

func init() {
	_, file, _, _ := runtime.Caller(1)
	apppath, _ := filepath.Abs(filepath.Dir(filepath.Join(file,
		".."+string(filepath.Separator))))
	beego.TestBeegoInit(apppath)
	beego.SetLevel(logs.LevelInfo)
}
开发者ID:Lkyzlwj,项目名称:Graduate,代码行数:7,代码来源:rawtrainrecord_test.go


示例2: main

func main() {
	models.Init()
	jobs.InitJobs()

	// 设置默认404页面
	beego.Errorhandler("404", func(rw http.ResponseWriter, r *http.Request) {
		t, _ := template.New("404.html").ParseFiles(beego.ViewsPath + "/error/404.html")
		data := make(map[string]interface{})
		data["content"] = "page not found"
		t.Execute(rw, data)
	})

	// 生产环境不输出debug日志
	if beego.AppConfig.String("runmode") == "prod" {
		beego.SetLevel(beego.LevelInformational)
	}
	beego.AppConfig.Set("version", VERSION)

	// 路由设置
	beego.Router("/", &controllers.MainController{}, "*:Index")
	beego.Router("/login", &controllers.MainController{}, "*:Login")
	beego.Router("/logout", &controllers.MainController{}, "*:Logout")
	beego.Router("/profile", &controllers.MainController{}, "*:Profile")
	beego.Router("/gettime", &controllers.MainController{}, "*:GetTime")
	beego.Router("/help", &controllers.HelpController{}, "*:Index")
	beego.AutoRouter(&controllers.TaskController{})
	beego.AutoRouter(&controllers.GroupController{})

	beego.SessionOn = true
	beego.Run()
}
开发者ID:wuwenbao,项目名称:webcron,代码行数:31,代码来源: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: 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


示例5: main

func main() {
	//	beego.SetLogger("file", `{"filename":"logs/test.log"}`)
	mode := beego.AppConfig.String("runmode")
	if mode == "prod" {
		beego.SetLevel(beego.LevelInformational)
	}
	//	go demo()
	beego.Run()
}
开发者ID:aleSheng,项目名称:apigo,代码行数:9,代码来源:main.go


示例6: 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() {
	models.InitModels()

	routers.IsPro = beego.RunMode == "prod"
	if routers.IsPro {
		beego.SetLevel(beego.LevelInfo)
		os.Mkdir("./log", os.ModePerm)
		beego.BeeLogger.SetLogger("file", `{"filename": "log/log"}`)
	}

	routers.InitApp()
}
开发者ID:ningjh,项目名称:beeweb,代码行数:15,代码来源:beeweb.go


示例7: Get

func (c *MainController) Get() {
	// c.Data["Website"] = "beego.me"
	// c.Data["Email"] = "[email protected]"
	// c.TplName = "index.tpl"
	c.Ctx.WriteString("appname: " + beego.AppConfig.String("appname") +
		"\nhttpport: " + beego.AppConfig.String("httpport") +
		"\nrunmode: " + beego.AppConfig.String("runmode"))

	beego.Trace("trace 1")
	beego.Info("info 1")
	beego.SetLevel(beego.LevelInformational)
	beego.Trace("trace 2")
	beego.Info("info 2")
}
开发者ID:CodyGuo,项目名称:Go-Cody,代码行数:14,代码来源:default.go


示例8: 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


示例9: 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


示例10: 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() {
	models.InitModels()
	routers.InitRouter()

	// Set App version and log level.
	beego.AppName = models.Cfg.MustValue("beego", "app_name")
	beego.HttpPort = models.Cfg.MustInt("beego", "http_port_"+beego.RunMode)

	routers.IsPro = beego.RunMode == "pro"
	if routers.IsPro {
		beego.SetLevel(beego.LevelInfo)
		os.Mkdir("./log", os.ModePerm)
		beego.BeeLogger.SetLogger("file", `{"filename": "log/log"}`)
	}
}
开发者ID:jueebushe,项目名称:beeweb,代码行数:18,代码来源:beeweb.go


示例11: 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


示例12: 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


示例13: init

func init() {
	//ceshi
	//设置log格式
	beego.SetLogger("file", `{"filename":"logs/server.log"}`)
	beego.SetLevel(beego.LevelDebug)

	//设置session
	/*kkk
	beego.SessionOn = true
	beego.SessionProvider = "redis"
	beego.SessionSavePath = "192.168.15.43:6379"
	beego.SessionName = "LMSsessionID"
	beego.SessionGCMaxLifetime = 60
	beego.SessionCookieLifeTime = 60
	*/
}
开发者ID:tcdog001,项目名称:ums,代码行数:16,代码来源:main.go


示例14: init

func init() {
	beego.AppConfigPath = "conf/app.conf"
	beego.SetStaticPath("/js", "public/js")
	beego.SetStaticPath("/img", "public/img")
	beego.SetStaticPath("/favicon.ico", "public/img/favicon.ico")
	beego.SetStaticPath("/css", "public/css")
	beego.SetStaticPath("/html", "tpl")
	beego.SetStaticPath("/admin/js", "public/admin/js")
	beego.SetStaticPath("/admin/img", "public/admin/img")
	beego.SetStaticPath("/admin/css", "public/admin/css")
	beego.SetStaticPath("/admin/assets", "public/admin")
	beego.SetLevel(beego.LevelDebug)
	beego.SetLogFuncCall(true)
	beego.BeeLogger.SetLogFuncCallDepth(4)
	bm, _ = cache.NewCache("memory", `{"interval":60}`)
}
开发者ID:ishawge,项目名称:thinkgo,代码行数:16,代码来源:main.go


示例15: init

func init() {
	//runtime.GOMAXPROCS(runtime.NumCPU())

	// Set App version and log level.
	routers.IsPro = beego.AppConfig.String("runmode") == "pro"
	if routers.IsPro {
		beego.SetLevel(beego.LevelInfo)

		beego.Info("Beego Web", APP_VER)

		os.Mkdir("./log", os.ModePerm)
		beego.BeeLogger.SetLogger("file", "log/log")
	} else {
		// beewatch.Start(beewatch.Trace)
	}
}
开发者ID:kobeyyf,项目名称:beeweb,代码行数:16,代码来源:beeweb.go


示例16: initialize

func initialize() {

	models.InitModels()

	// Set App version and log level.
	beego.AppName = models.Cfg.MustValue("beego", "app_name")
	beego.RunMode = models.Cfg.MustValue("beego", "run_mode")

	controllers.IsPro = beego.RunMode == "prod"
	if controllers.IsPro {
		beego.SetLevel(beego.LevelInfo)
		os.Mkdir("./log", os.ModePerm)
		beego.BeeLogger.SetLogger("file", `{"filename": "log/log"}`)
	}
	controllers.InitApp()
}
开发者ID:javazhen,项目名称:blog,代码行数:16,代码来源:main.go


示例17: init

func init() {
	runtime.GOMAXPROCS(runtime.NumCPU())

	// Set App version and log level.
	if beego.AppConfig.String("runmode") == "pro" {
		beego.SetLevel(beego.LevelInfo)

		beego.Info("Beego Web", APP_VER)

		os.Mkdir("./log", os.ModePerm)
		filew := beego.NewFileWriter("log/log", true)
		err := filew.StartLogger()
		if err != nil {
			beego.Critical("NewFileWriter ->", err)
		}
	}
}
开发者ID:JoeyFan,项目名称:beeweb,代码行数:17,代码来源:beeweb.go


示例18: Get

func (c *MainController) Get() {
	c.Ctx.WriteString("appname: " + beego.AppConfig.String("appname") +
		"\nhttpport: " + beego.AppConfig.String("httpport") +
		"\nrunmode: " + beego.AppConfig.String("runmode"))

	c.Ctx.WriteString("\n\nappname: " + beego.AppName +
		"\nhttpport: " + strconv.Itoa(beego.HttpPort) +
		"\nrunmode: " + beego.RunMode)

	beego.Trace("trace test1..")
	beego.Info("test1...")

	beego.SetLevel(beego.LevelInformational)

	beego.Trace("trace test2..")
	beego.Info("test2...")
}
开发者ID:zykzhang,项目名称:practice,代码行数:17,代码来源:default.go


示例19: init

func init() {
	//设置log格式
	beego.SetLogger("file", `{"filename":"logs/server.log"}`)
	beego.SetLevel(beego.LevelDebug)

	//设置下载脚本目录
	beego.SetStaticPath("/script_download", "script_download")

	//设置session
	/*
		beego.SessionOn = true
		beego.SessionProvider = "redis"
		beego.SessionSavePath = "192.168.15.43:6379"
		beego.SessionName = "LMSsessionID"
		beego.SessionGCMaxLifetime = 60
		beego.SessionCookieLifeTime = 60
	*/
}
开发者ID:tcdog001,项目名称:szm_lms,代码行数:18,代码来源:main.go


示例20: Get

func (this *MainController) Get() {
	// 配置管理
	this.Ctx.WriteString("AppName: " + beego.AppConfig.String("appname") +
		"\nRunMode: " + beego.AppConfig.String("runmode"))

	// 默认参数
	this.Ctx.WriteString("\n\nAppName: " + beego.AppName +
		"\nRunMode: " + beego.RunMode)

	// 日志级别
	beego.Trace("Trace test1")
	beego.Info("Info test1")

	beego.SetLevel(beego.LevelInfo)

	beego.Trace("Trace test2")
	beego.Info("Info test2")
}
开发者ID:443752009,项目名称:go-web-foundation,代码行数:18,代码来源:default.go



注:本文中的github.com/astaxie/beego.SetLevel函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang beego.SetLogger函数代码示例发布时间:2022-05-24
下一篇:
Golang beego.Run函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap