Comments (3)
ok.看了一下你的问题,时间这个我在写的时候我自己都发现了只是后面赶着写完就push上去了然后也没有看2333,OK至于消息标签我后续可能改成可以自定义配置的。
from sprout.
现在的日志输出信息:
[ INFO ] - Date: 2020-22-22 11:22:33.1234 AM - Position: main.go|main.main|22 - Message: custom message
能不能提供一个选项,可以去掉
Date:
、Position:
以及Message:
这几个文本,因为很显而易见这栏就是时间,这栏就是代码位置,感觉没有必要,加上也增大了日志每行的长度最终的效果就是
[ INFO ] - 2020-22-22 11:22:33.1234 AM - main.go|main.main|22 - custom message
另外这个 AM / PM 是否有必要存在呢,既然都已经是 24 小时制了?
现在upgrade到v1.1.5版本即可自定义消息输出格式~
自定义标签名字必须是{level}
{time}
{position}
{message}
自定义标签的位置就是程序运行时输出对应的日志消息的位置!!!!
例如下面我自定义的
package main
import (
"github.com/higker/logker"
"strings"
)
//type Formatting string
// logKer library Test
func main() {
//现在upgrade到v1.1.5版本即可自定义消息输出格式~
//format := "{level} - {time} - {position} - {message}"
var log logker.Logger
format := "{level} - 时间 {time} - 位置 {position} - 消息 {message}" //This version was modified from v 1.1.5
log = logker.NewClog(logker.DEBUG, logker.Shanghai, format)
log.Debug("DEBUG %s","自定义日志消息匹配符测试")
log.Info("%v", log)
log.Warning("%v", logker.Shanghai)
log.Error("ERROR")
}
OutPut
[ DEBUG ] - 时间 2020-04-20 11:57:23.8927 - 位置 main.go|main.main:23 - 消息 DEBUG 自定义日志消息匹配符测试
[ INFO ] - 时间 2020-04-20 11:57:23.8928 - 位置 main.go|main.main:24 - 消息 &{0 Asia/Shanghai 0xc00008e220 {level} - 时间 {t位置 {position} - 消息 {message}}
[WARNING] - 时间 2020-04-20 11:57:23.8928 - 位置 main.go|main.main:25 - 消息 Asia/Shanghai
[ ERROR ] - 时间 2020-04-20 11:57:23.8929 - 位置 main.go|main.main:26 - 消息 ERROR
from sprout.
func main() {
var log logker.Logger
format := "{level} - Date: {time} - 位置{position} - Message: {message}" //This version was modified from v 1.1.0
log = logker.NewClog(logker.INFO, logker.Shanghai, format)
log.Info("%v", log)
log.Warning("%v", logker.Shanghai)
}
自定义格式化formatting : //ormat := "{level} - {time} - {position} - {message}
但是必须是👆的标签名字 {level}
{time}
{position}
{message}
是这样的,{}
号的!!!程序就会根据你自定义的格式
from sprout.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sprout.