20 Star 44 Fork 19

baickl / logger

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

logger

这是一个基于GO语言的服务器日志系统,使用起来会非常方便,API接口简洁,易于嵌入到目前的项目工程中。

特性

1.支持按日备份,跨天会创建新的日志
2.支持按大小切分日志,如果单个日志文件超过指定上限,会重新创建日志
3.支持控制台不同日志不同颜色显示,DEBUG和INFO日志默认输出白色,WARN输出黄色,ERROR输出红色
4.支持捕获异常操作,并将异常信息及出错时运行堆栈保存在exception目录中,按时间存放

获取

go get github.com/baickl/logger

示例

import(
    "github.com/baickl/logger"
)

//初始化
logger.Initialize("./log","LoginServer") 
  
//设置选项 
logger.SetConsole(true) 
logger.SetLevel(logger.DEBUG)
  
//单一输出 
logger.Debug("I'm debug log!") 
logger.Info("I'm info log!") 
logger.Warn("I'm warn log!") 
logger.Error("I'm error log!") 
  
//格式化输出 
logger.Debugf("I'm %s log! ","debug") 
logger.Infof("I'm %s log!","info")
logger.Warnf("I'm %s log!","warn")
logger.Errorf("I'm %s log!","error")
  
//行输出
logger.Debugln("I'm","debug","log!") 
logger.Infoln("I'm","info","log!")
logger.Warnln("I'm","warn","log!") 
logger.Errorln("I'm","error","log!")

//异常捕获
defer logger.CatchException()
panic(err)  //此panic会被logger.CatchException()捕获,并保存到exception目录
The MIT License (MIT) Copyright (c) 2015 baickl Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

这是一个基于GO语言的服务器日志系统,使用起来会非常方便,API接口简洁,易于嵌入到目前的项目工程中。 1.支持按日备份,跨天会创建新的日志 2.支持按大小切分日志,如果单个日志文件超过指定上限,会重新创建日志 3.支持控制台不同日志不同颜色显示,DEBUG和INFO日志默认输出白色,WARN输出黄色,ERROR输出红色 4.支持捕获异常操作,并将异常信息及出错时运行堆栈保存在exception目录中,按时间存放 展开 收起
Go
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Go
1
https://gitee.com/baickl/logger.git
git@gitee.com:baickl/logger.git
baickl
logger
logger
master

搜索帮助