This repository was archived by the owner on May 19, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +55
-3
lines changed
Expand file tree Collapse file tree 2 files changed +55
-3
lines changed Original file line number Diff line number Diff line change 11logs-go-gin
22-----------
33
4- Logger fo gin gonic
4+ Logger fo gin gonic
5+
6+ ## Usage
7+
8+ Initiate new [ logger] ( https://github.com/microparts/logs-go ) with prefilled ` logs.Config ` and use it to initiate new gin logger
9+
10+ ``` go
11+ package main
12+
13+ import (
14+ " time"
15+
16+ " github.com/gin-gonic/gin"
17+ " github.com/microparts/logs-go"
18+ " github.com/microparts/logs-go-gin"
19+ )
20+
21+ func main () {
22+ // initiate logs-go
23+ conf := &logs.Config {
24+ Level:" warn" ,
25+ Format: " text" ,
26+ Sentry: &logs.SentryConfig {
27+ Enable: true ,
28+ Stage:" test" ,
29+ DSN: " http://dsn.sentry.com" ,
30+ ResponseTimeout: 0 ,
31+ StackTrace: logs.StackTraceConfig {
32+ Enable: true ,
33+ },
34+ },
35+ }
36+
37+ l , err := logs.NewLogger (conf)
38+ if err != nil {
39+ panic (err)
40+ }
41+
42+ r := gin.New ()
43+ r.Use (ginLogger.NewLogger (l), gin.Recovery ())
44+
45+ // pingpong
46+ r.GET (" /ping" , func (c *gin.Context ) {
47+ c.Data (200 , " text/plain" , []byte (" pong" ))
48+ })
49+
50+ _ = r.Run (" 127.0.0.1:8080" )
51+ }
52+ ```
53+
54+ ## Licence
55+
56+ The software is provided under [ MIT Licence] ( LICENCE ) .
Original file line number Diff line number Diff line change 88 "github.com/sirupsen/logrus"
99)
1010
11- // MuxLogger logs gin gonic actions
12- func GinLogger (l * logrus.Logger ) gin.HandlerFunc {
11+ // NewLogger logs gin gonic actions
12+ func NewLogger (l * logrus.Logger ) gin.HandlerFunc {
1313 hostname , err := os .Hostname ()
1414 if err != nil {
1515 hostname = "unknown"
You can’t perform that action at this time.
0 commit comments