All Projects → ThreeKing2018 → k3log

ThreeKing2018 / k3log

Licence: Apache-2.0 license
三大王日志,一款开箱即用且高效,快捷,安全的golang日志,基于uber zap

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to k3log

logging
mod: zap logging in golang
Stars: ✭ 44 (+37.5%)
Mutual labels:  log, zap
logy
Parse log files like a pro with this awesome CLI tool. Paginate and filter with great ease.
Stars: ✭ 28 (-12.5%)
Mutual labels:  log
Xlog
Android logger, pretty, powerful and flexible, log to everywhere, save to file, all you want is here.
Stars: ✭ 2,468 (+7612.5%)
Mutual labels:  log
Awstats
AWStats Log Analyzer project (official sources)
Stars: ✭ 238 (+643.75%)
Mutual labels:  log
Pgbadger
A fast PostgreSQL Log Analyzer
Stars: ✭ 2,522 (+7781.25%)
Mutual labels:  log
Fluent Bit
Fast and Lightweight Logs and Metrics processor for Linux, BSD, OSX and Windows
Stars: ✭ 3,223 (+9971.88%)
Mutual labels:  log
Masterchief
C# 开发辅助类库,和士官长一样身经百战且越战越勇的战争机器,能力无人能出其右。
Stars: ✭ 190 (+493.75%)
Mutual labels:  log
golang-example-app
Example application
Stars: ✭ 138 (+331.25%)
Mutual labels:  zap
Mars
Mars is a cross-platform network component developed by WeChat.
Stars: ✭ 15,912 (+49625%)
Mutual labels:  log
Sagan
** README ** This repo has MOVED to https://github.com/quadrantsec/sagan
Stars: ✭ 236 (+637.5%)
Mutual labels:  log
Wordpress Simple History
🔍🕵️‍♀️ WordPress audit log that track user changes in WordPress admin using a nice activity feed.
Stars: ✭ 232 (+625%)
Mutual labels:  log
Lumberjackconsole
On-device CocoaLumberjack console with support for search, adjust levels, copying and more.
Stars: ✭ 205 (+540.63%)
Mutual labels:  log
Base
🍁 Base是针对于Android开发封装好一些常用的基类,主要包括通用的Adapter、Activity、Fragment、Dialog等、和一些常用的Util类,只为更简单。
Stars: ✭ 249 (+678.13%)
Mutual labels:  log
Sensitive
🔐Sensitive log tool for java, based on java annotation. (基于注解的 java 日志脱敏框架,更加优雅的日志打印)
Stars: ✭ 200 (+525%)
Mutual labels:  log
git-tui
Collection of human friendly terminal interface for git.
Stars: ✭ 95 (+196.88%)
Mutual labels:  log
Sematext Agent Docker
Sematext Docker Agent - host + container metrics, logs & event collector
Stars: ✭ 194 (+506.25%)
Mutual labels:  log
Golog
A high-performant Logging Foundation for Go Applications. X3 faster than the rest leveled loggers.
Stars: ✭ 208 (+550%)
Mutual labels:  log
Laravel Log Viewer
🐪 Laravel log viewer
Stars: ✭ 2,726 (+8418.75%)
Mutual labels:  log
log
Aplus Framework Log Library
Stars: ✭ 14 (-56.25%)
Mutual labels:  log
datalogger
DataLogger foi projetado para ser uma biblioteca simples de log com suporte a vários providers.
Stars: ✭ 46 (+43.75%)
Mutual labels:  log

k3log

一款开箱即用且高效,快捷,安全的golang日志,基于uber zap
实现日志切割,日志过期时间,动态改变日志的打印级别

导航

  1. 介绍
  2. 日志级别
  3. 设置参数
  4. 使用方法
  5. 动态改变日志的打印级别
  6. 效率
  7. Dump的使用

介绍

取名Three King Log

  • 由uber zap 日志扩展而来
  • 实现分隔,异步,动态级别打印,json/txt
  • 以key-value形式打印日志,适合项目里使用
  • 加入Dump打印数据详细类型结构,融入go-spew调度利器

文档参考

安装

go get -u github.com/ThreeKing2018/k3log

日志级别

  • Debug 调度使用, 程序继续运行
  • Info 提示使用, 程序继续运行
  • Warn 警告使用, 程序继续运行
  • Error 错误使用, 程序继续运行
  • Panic 恐慌的,退出函数,不会退出应用唾弃,会执行defer
  • Fatal 致命的,退出应用程序,不会执行defer,因为底层多一个os.Exit
  • Dump 打印数据类型,方便调度,级别为:Debug

TOP

设置参数

  • WithFilename 日志保存路径
  • WithLogLevel 日志记录级别
  • WithMaxSize 日志分割的尺寸 MB
  • WithMaxAge 分割日志保存的时间 day
  • WithStacktrace 记录堆栈的级别
  • WithIsStdOut 是否标准输出console输出
  • WithProjectName 项目名称
  • WithLogType 日志类型,普通 或 json

TOP

使用方法

  • 简单使用
Debug("debug日志", 1)
Info("info日志", 2)
Warn("warn日志", 3)
Error("error日志", 4)
Panic("panic", 5)
Fatal("fatal", 6)
Dump("dump", 7)

TOP

  • 开发使用
NewDevelopment("dev", "log.txt")
defer Sync()
Info("Info", "dev")
  • 开发使用2
SetLogger(conf.WithIsStdOut(true),
		conf.WithLogType(conf.LogJsontype))
	Debug("self test", 100)
  • 开发使用3
SetLogger(conf.WithLogType(conf.LogJsontype), //打印json格式
    conf.WithProjectName("Zelog日志"),          //设置项目名称
    conf.WithFilename("log.txt"),             //设置输出文件名,或输出的路径
Debug("debug日志", 1)
Info("info日志", 2)
Warn("warn日志", 3)
Error("error日志", 4)
Panic("panic", 5)
Fatal("fatal", 6)

TOP

  • 生产使用
NewProducttion("pro", "log.txt")
defer Sync()
Error("pro", "ok")
  • 生产使用2
SetLogger(conf.WithLogType(conf.LogJsontype), //打印json格式
		conf.WithProjectName("Zelog日志"),          //设置项目名称
		conf.WithFilename("log.txt"),             //设置输出文件名,或输出的路径
		conf.WithLogLevel(conf.InfoLevel),        //设置日志级别,默认debug
		conf.WithMaxAge(30),                      //日志保存天数,默认30天
		conf.WithMaxSize(512),                    //多少M进行分隔日志,默认100M
		conf.WithIsStdOut(false)) //是否同时输出控制台
defer Sync()
Debug("debug日志", 1)
Info("info日志", 2)
Warn("warn日志", 3)
Error("error日志", 4)
Panic("panic", 5)
Fatal("fatal", 6)

TOP

动态改变日志的打印级别

Info("aa", 11)
SetLogLevel(conf.InfoLevel)
Info("info", 100)
Warn("warn", 200)
SetLogLevel(conf.ErrorLevel)
Info("info-100", 300) //这个无法输出,因为上面设置日志级别为:error
Error("err", 400)

效率

runtime.GOMAXPROCS(runtime.NumCPU())
BenchmarkInfo-4   	  100000	     10776 ns/op
BenchmarkInfo-4   	  200000	     12442 ns/op

TOP

Dump的使用

  • 级别为:debug
type s struct {
    Name string
    Age int
}
SetLogger(conf.WithIsStdOut(true))
Dump("name", "dump", "s", s{Name:"k3", Age: 2})

//{"name": "(string) (len=4) \"dump\"", "s": "(k3log.s) { Name: (string) (len=2) \"k3\", Age: (int) 2}"}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].