Skip to content

Commit

Permalink
readme add sample code
Browse files Browse the repository at this point in the history
  • Loading branch information
chalvern committed Jun 9, 2019
1 parent 6d7a22a commit c420bcd
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,36 @@ all methods of zap:

## example

you can find example in [examples](./examples).
you can find example in [examples](./examples).

```go
// cat ./examples/default/main.go
package main

import "github.com/chalvern/sugar"

func main() {

sugar.Debug("default development sugar of chalvern")
myCustomLogger()
myCustomLogger2()

sugar.InitProductionSugar()
sugar.Debug("should not be printed")
sugar.Info("default production sugar of chalvern")
myCustomLogger()
myCustomLogger2()
}

func myCustomLogger() {
myLogger := sugar.NewLoggerOf("my_custom_logger")
myLogger.Info("log of myCustomLogger info")
myLogger.Warn("log of myCustomLogger warn")
}

func myCustomLogger2() {
myLogger := sugar.NewLoggerOf("my_custom_logger_2")
myLogger.Info("log of myCustomLogger2 info")
myLogger.Warn("log of myCustomLogger2 warn")
}
```

0 comments on commit c420bcd

Please sign in to comment.