-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
big-uncle
committed
Dec 24, 2020
1 parent
1284827
commit 06acfcb
Showing
1 changed file
with
33 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,43 @@ | ||
# zap_mate | ||
The `zap_mate` is a simple packaging tools of [zap](https://github.com/uber-go/zap). It combines zap, viper, lumberjack and many other tools to integrate it, making zap configuration lighter, more convenient and faster, so as to better assist developers. | ||
|
||
|
||
***The `zap_mate` is a simple packaging tools of [zap](https://github.com/uber-go/zap). It combines zap, viper, lumberjack and many other tools to integrate it, making zap configuration lighter, more convenient and faster, so as to better assist developers.*** | ||
|
||
See the example folder for more details ... | ||
|
||
## Usage | ||
### Use the origin ZAP logger | ||
- Example | ||
```go | ||
|
||
Because asyn logs will cause a lot of memory escape, zap_mate does not recommend or support the use of asyn logs. | ||
logger := zap_mate.NewZapLogger("../test.yaml", "default") | ||
|
||
If you have a scene with very high real-time performance, then it is recommended that you implement the asyn log yourself. In fact, it is very easy. | ||
logger.Debug("Hi, boy!") | ||
|
||
logger.Info("I am zap_mate!") | ||
|
||
``` | ||
### Use the mate logger | ||
If you want to use mate logger: | ||
> The mate logger supports async and sync write logs, and extends all feature of origin zap. | ||
- Example | ||
```go | ||
type mylogger struct{ | ||
field string | ||
msg string | ||
*zap.Logger | ||
} | ||
|
||
var logger=make(chan *zmylogger,1000) | ||
go func (){ | ||
for { | ||
select zl<-logger: | ||
zl.Info(zl.msg,zl.field) | ||
} | ||
}() | ||
``` | ||
logger := zap_mate.NewZapMateLogger("../test.yaml", "default") | ||
logger.SetAsyncer(10) | ||
logger.AsyncDebug("Hi, boy!") | ||
logger.AsyncInfo("I am zap_mate!") | ||
logger.Flush() | ||
logger.Warn("Who are you?") | ||
sugar := logger.Sugar() | ||
sugar.Error("I am Sugar!") | ||
sugar.DPanic("How are you?") | ||
``` |