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

Golang logs.NewLogger函数代码示例

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

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



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

示例1: init_log

func init_log(cfg *Config) error {
	//数据接收日志
	dlog = logs.NewLogger(100)
	dlog.EnableFuncCallDepth(true)
	dlog.SetLevel(cfg.LOG_LEVEL)
	if err := dlog.SetLogger("file", fmt.Sprintf(`{"filename":"%s/data.log","rotate":true,"maxdays":%d}`,
		cfg.LOG_DIR, cfg.LOG_EXPIRE_DAYS)); err != nil {
		return err
	}
	//网络设备日志
	nlog = logs.NewLogger(100)
	nlog.EnableFuncCallDepth(true)
	nlog.SetLevel(cfg.LOG_LEVEL)
	if err := nlog.SetLogger("file", fmt.Sprintf(`{"filename":"%s/netdevice.log","rotate":true,"maxdays":%d}`,
		cfg.LOG_DIR, cfg.LOG_EXPIRE_DAYS)); err != nil {
		return err
	}

	slog = logs.NewLogger(100)
	slog.EnableFuncCallDepth(true)
	slog.SetLevel(cfg.LOG_LEVEL)
	if err := slog.SetLogger("file", fmt.Sprintf(`{"filename":"%s/server.log","rotate":true,"maxdays":%d}`,
		cfg.LOG_DIR, cfg.LOG_EXPIRE_DAYS)); err != nil {
		return err
	}
	return nil
	//客户端日志
	//
}
开发者ID:y8y,项目名称:OWL-v3,代码行数:29,代码来源:log.go


示例2: init

func init() {
	normal_log = logs.NewLogger(10000)
	normal_log.EnableFuncCallDepth(true)
	access_log_file := beego.AppConfig.String("access_log")
	normal_log.SetLogger("file", `{"filename":"`+access_log_file+`"}`)
	error_log = logs.NewLogger(10000)
	error_log.EnableFuncCallDepth(true)
	error_log_file := beego.AppConfig.String("error_log")
	error_log.SetLogger("file", `{"filename":"`+error_log_file+`"}`)
}
开发者ID:a4m,项目名称:bae_ssh_manage,代码行数:10,代码来源:sshlog.go


示例3: main

func main() {
	log := logs.NewLogger(10000)
	log.SetLogger("file", `{"filename":"/tmp/wallpaper.log"}`)
	log.Info("Start===================")
	v := Bing{}
	req := httplib.Get("http://www.bing.com/HPImageArchive.aspx?format=json&idx=0&n=1")
	err := req.ToXml(&v)

	if len(v.Images) > 0 && err == nil {
		pic := httplib.Get(bingURL + v.Images[0].Url)
		fmt.Println(file_path)
		err = pic.ToFile(file_path)
		if err != nil {
			log.Error("save file error %v.............", err)
		} else {
			log.Info("download wallpeper success..........")
			cmd := exec.Command("gsettings", "set", "org.gnome.desktop.background", "picture-uri", fmt.Sprintf("file:%s", file_path))
			err := cmd.Start()
			log.Info("Waiting for command to finish.........")
			err = cmd.Wait()
			log.Info("Command finished with error: %v", err)
			if err != nil {
				log.Error("%v............", err)
			}
			log.Info("set wallpeper success..........")
		}
	}
	log.Info("End===================")
}
开发者ID:ikbear,项目名称:go_code,代码行数:29,代码来源:linux_wall.go


示例4: init

func init() {
	//根据随机时间种子实例化随机数
	newRand = rand.New(rand.NewSource(time.Now().UnixNano()))
	//如果没有日志目录则创建日志目录
	_, err := os.Open("log")
	if err != nil && os.IsNotExist(err) {
		os.Mkdir("log", 0777)
	}
	//初始化日志
	log = logs.NewLogger(10000)
	log.SetLogger("file", `{"filename":"log/kingdoms.log"}`)
	//初始化又拍云
	/// 初始化空间
	ku = upyun.NewUpYun("kingdoms", beego.AppConfig.String("UpyunAccount"), beego.AppConfig.String("UpyunPassword"))
	ku.SetApiDomain("v0.api.upyun.com")
	//初始化技能
	allskill = &logic.AllSkill{}
	//初始化所有图片json值
	updateImage()
	//初始化游戏数据
	cardRanks = "100,500,2000,10000"
	chuanqi = []int{16, 132, 181, 230, 278, 308, 501, 539, 566}
	shenjiang = []int{17, 18, 24, 26, 57, 84, 91, 98, 180, 190, 192, 196, 233, 294, 395, 575}
	hujiang = []int{14, 20, 25, 27, 29, 31, 32, 33, 129, 130, 131, 183, 191, 215, 220, 225, 229, 237, 283, 284, 285, 288, 293, 296, 297, 352, 383, 450, 451, 479, 495, 530, 546, 574, 576, 577}
	putong = []int{20}
	xiaobing1 = []int{1001, 1002, 1003, 1004, 1005, 1006}
	xiaobing2 = []int{1007, 1008, 1009, 1010, 1011, 1012}
	xiaobing3 = []int{1013, 1014, 1015, 1016, 1017, 1018}
	RliveCost = 10
	//赋值所有卡牌
	SetAllCards()
}
开发者ID:cnhans,项目名称:kingdoms,代码行数:32,代码来源:index.go


示例5: init

func init() {
	log = logs.NewLogger(10000)
	log.SetLogger("file", `{
		"filename": "storage/logs/access.log",
		"maxdays": 365
	}`)
}
开发者ID:kevinxu001,项目名称:typecho-app-store,代码行数:7,代码来源:logger.go


示例6: init

func init() {
	log = logs.NewLogger(10000)
	log.SetLogger("console", `{"level": 10}`)
	log.SetLevel(logs.LevelDebug)
	log.EnableFuncCallDepth(true)
	log.SetLogFuncCallDepth(3)
	log.Async()
}
开发者ID:nevernet,项目名称:logger,代码行数:8,代码来源:logger.go


示例7: GetLogger

func GetLogger() *logs.BeeLogger {
	if logger == nil {
		logger = logs.NewLogger(1000)
		logger.SetLevel(logs.LevelInfo)
		//		today := time.Now().YearDay()
		logger.SetLogger("file", `{"filename":"logs/snp.log","daily":true}`)
	}
	return logger
}
开发者ID:wuxu92,项目名称:snp,代码行数:9,代码来源:log.go


示例8: WriteErrorLog

func WriteErrorLog(format string, v ...interface{}) {
	log := logs.NewLogger(10000)
	fname := getLogFileName()
	sfile := fmt.Sprintf("{\"filename\":\"%s\"}", fname)
	log.SetLogger("file", sfile)
	//log.SetLogger("file", `{"filename":"solar.log"}`)

	log.Error(format, v...)
}
开发者ID:williamzhang2013,项目名称:solarzoom,代码行数:9,代码来源:utils.go


示例9: GetConsole

func GetConsole() *logs.BeeLogger {
	if console == nil {
		fmt.Println("new console logger")
		console = logs.NewLogger(1000)
		console.SetLevel(logs.LevelInfo)
		console.SetLogger("console", `{}`)
	}
	return console
}
开发者ID:wuxu92,项目名称:snp,代码行数:9,代码来源:log.go


示例10: InitLog

func InitLog(runmode, path string) {
	Log = logs.NewLogger(10000)

	if runmode == "dev" {
		Log.SetLogger("console", "")
	}

	Log.SetLogger("file", fmt.Sprintf("{\"filename\":\"%s\"}", path))

}
开发者ID:pombredanne,项目名称:wharf-1,代码行数:10,代码来源:logger.go


示例11: LogEngine

func (this *BeeLooger) LogEngine() {
	mylog := GetInstanceForMyLog()
	//初始化日志
	mylog = logs.NewLogger(10000)
	//设置日志引擎
	mylog.SetLogger("file", `"filename":"slygoblog.log","maxlines":11,"maxdays":1`)

	mylog.SetLogFuncCallDepth(2)
	mylog.EnableFuncCallDepth(false)
}
开发者ID:slygo,项目名称:slygoblog,代码行数:10,代码来源:mylog.go


示例12: init

func init() {
	Log = logs.NewLogger(10000)

	if setting.RunMode == "dev" {
		Log.SetLogger("console", "")
	}

	Log.SetLogger("file", fmt.Sprintf("{\"filename\":\"%s\"}", setting.LogPath))

}
开发者ID:rechen,项目名称:dockyard,代码行数:10,代码来源:logger.go


示例13: LogItemDelete

func LogItemDelete(item interface{}, deleter string) bool {
	log := logs.NewLogger(10000)
	log.SetLogger("file", `{"filename":"db/deletedItems.log"}`)
	if b, err := json.Marshal(item); err == nil {
		fmt.Println(b)
		beego.Warn("deleter: ", deleter, " item: ", string(b))
		log.Info("deleter: ", deleter, " item: ", string(b))
		return true
	}
	return false
}
开发者ID:zixinjian,项目名称:webo_dev,代码行数:11,代码来源:wblog.go


示例14: main

func main() {
	InitXml(&g_dbs) // 加载xml配置
	// log初始化
	beelog = logs.NewLogger(10000)
	beelog.SetLogger("file", `{"filename":"run.log"}`)
	beelog = beelog.Async()
	// errlog初始化
	errlog = logs.NewLogger(10000)
	errlog.SetLogger("file", `{"filename":"err.log"}`)
	errlog = errlog.Async()

	AlterMysqlDB("InnoDB", true)
	count := len(g_dbs.DBConfig)
	for i := 1; i < count; i++ {
		StartMerge(g_dbs.DBConfig[0], g_dbs.DBConfig[i])
	}
	AlterMysqlDB("MyISAM", false)

	return
}
开发者ID:zkbcoder,项目名称:gosrc,代码行数:20,代码来源:main.go


示例15: init

func init() {
	//如果没有日志目录则创建日志目录
	_, err := os.Open("log")
	if err != nil && os.IsNotExist(err) {
		os.Mkdir("log", 0777)
	}
	//初始化日志
	SocketLog = logs.NewLogger(10000)
	SocketLog.SetLogger("file", `{"filename":"log/socket.log"}`)
	//初始化客户端
	Clients = make(map[string]*websocket.Conn, 1000)
}
开发者ID:treejames,项目名称:woku_old,代码行数:12,代码来源:socket.go


示例16: init

func init() {
	//如果没有日志目录则创建日志目录
	_, err := os.Open("log")
	if err != nil && os.IsNotExist(err) {
		os.Mkdir("log", 0777)
	}
	//初始化日志
	ApiLog = logs.NewLogger(10000)
	ApiLog.SetLogger("file", `{"filename":"log/api.log"}`)
	//初始化邮箱
	mail = utils.NewEMail(`{"username":"[email protected]","password":"` + beego.AppConfig.String("EmailPassword") + `","host":"smtp.isletsacg.com","port":25}`)
}
开发者ID:treejames,项目名称:Dream,代码行数:12,代码来源:api.go


示例17: Jia

func (this *TestController) Jia() {

	utility.ViewLogin(this.Ctx)

	log := logs.NewLogger(10000)
	log.SetLogger("console", "")

	//log.Info(strconv.Itoa(int(datatype.Golang)))

	log.Info(this.Ctx.Input.Uri())
	this.TplNames = "test/index.html"
}
开发者ID:beerbubble,项目名称:MtimeCI,代码行数:12,代码来源:test.go


示例18: InitLog

func InitLog() error {
	lg = logs.NewLogger(100)
	lg.EnableFuncCallDepth(true)
	lg.SetLogger("console", "")
	param := fmt.Sprintf(`{"filename":"%s","rotate":true,"maxdays":%d}`,
		GlobalConfig.LOG_FILE, GlobalConfig.LOG_EXPIRE_DAYS)
	if err := lg.SetLogger("file", param); err != nil {
		return err
	}
	lg.SetLevel(GlobalConfig.LOG_LEVEL)
	return nil
}
开发者ID:TalkingData,项目名称:OWL-v3,代码行数:12,代码来源:log.go


示例19: CreateToken

// CreateToken return the token
func CreateToken() map[string]string {
	log := logs.NewLogger(10000)
	log.SetLogger("console", "")

	token := goJwt.New(goJwt.GetSigningMethod("RS256")) // Create a Token that will be signed with RSA 256.
	token.Claims["ID"] = "This is my super fake ID"
	token.Claims["exp"] = time.Now().Unix() + 36000
	// The claims object allows you to store information in the actual token.
	tokenString, _ := token.SignedString(RSAKeys.PrivateKey)
	// tokenString Contains the actual token you should share with your client.
	return map[string]string{"token": tokenString}
}
开发者ID:ngaut,项目名称:beego,代码行数:13,代码来源:jwt.go


示例20: newLogger

// 初始化日志模块
func newLogger(config LogConfig, isDaily bool) (*logs.BeeLogger, error) {
	var logger *logs.BeeLogger

	var configInner logConfigInner
	if config.Filename == "" {
		return logger, errors.New("文件名不能为空哈")
	}
	configInner.Filename = config.Filename

	if config.Maxlines == 0 {
		config.Maxlines = 1000000
	}
	configInner.Maxlines = config.Maxlines

	configInner.Daily = isDaily

	if config.Maxdays == 0 {
		config.Maxdays = 7
	}
	configInner.Maxdays = config.Maxdays

	logLevel := map[string]int{
		"error": logs.LevelError,
		"warn":  logs.LevelWarning,
		"info":  logs.LevelInformational,
	}
	var logLevelInt int
	if config.Level == "" {
		logLevelInt = logs.LevelInformational
	} else {
		var ok bool
		logLevelInt, ok = logLevel[config.Level]
		if ok == false {
			return logger, errors.New("日志等级设置不正确")
		}
	}
	configInner.Level = logLevelInt
	configInner.Rotate = true

	// 普通日志
	logger = logs.NewLogger(10000)
	logConfigString, err := json.Marshal(&configInner)
	if err != nil {
		return logger, err
	}

	err = logger.SetLogger("file", string(logConfigString))
	if err != nil {
		return logger, err
	}

	return logger, nil
}
开发者ID:fishedee,项目名称:reproxy,代码行数:54,代码来源:log.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang logs.BeeLogger类代码示例发布时间:2022-05-24
下一篇:
Golang httplib.Post函数代码示例发布时间: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