Move readme parts to their corresponding packages
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
## Log
|
||||
|
||||
Package `log` wraps [logrus](https://github.com/sirupsen/logrus) with a set of
|
||||
convenient short functions. It can also add values to context for future
|
||||
logging.
|
||||
|
||||
```go
|
||||
import "github.com/localhots/gobelt/log"
|
||||
```
|
||||
|
||||
```go
|
||||
ctx := context.Background()
|
||||
ctx = log.ContextWithFields(ctx, log.F{"email": params["email"]})
|
||||
|
||||
user, err := signup(ctx, params)
|
||||
if err != nil {
|
||||
log.Errorf(ctx, "Signup failed: %v", err)
|
||||
// [ERRO] Signup failed: db: duplicate entry email=bob@example.com
|
||||
return
|
||||
}
|
||||
|
||||
log.Info(ctx, "New user signed up", log.F{
|
||||
"id": user.ID,
|
||||
"name": user.Name,
|
||||
})
|
||||
// [INFO] New user signed up email=bob@example.com id=14 name="Bob Fierce"
|
||||
```
|
||||
Reference in New Issue
Block a user