Skip to content

Commit

Permalink
add usage GUID
Browse files Browse the repository at this point in the history
  • Loading branch information
big-uncle committed Dec 24, 2020
1 parent 1284827 commit 06acfcb
Showing 1 changed file with 33 additions and 18 deletions.
51 changes: 33 additions & 18 deletions README.md
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?")
```

0 comments on commit 06acfcb

Please sign in to comment.