Skip to content

Commit f0e564e

Browse files
authored
refactor (#8)
Signed-off-by: qicz <[email protected]>
1 parent 96290f9 commit f0e564e

File tree

11 files changed

+304
-121
lines changed

11 files changed

+304
-121
lines changed

app/app.go

+12-23
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,22 @@
1818
package app
1919

2020
import (
21-
"os"
22-
23-
"github.com/acmestack/devstack/http"
21+
"github.com/acmestack/devstack/app/settings"
2422
"github.com/acmestack/devstack/logging"
25-
"github.com/acmestack/devstack/settings"
2623
)
2724

28-
type App struct {
29-
setting *settings.Setting
30-
}
31-
32-
var app *App
25+
var (
26+
Logger logging.Logger
27+
// SugaredLogger *zap.SugaredLogger
28+
)
3329

34-
func Run(enginePatch http.EnginePatchFunc, patch ...interface{}) {
35-
writer := logging.MultiWriter()
36-
cfg := settings.NewSetting(settings.AppConfigurations, patch...)
30+
func Run(routerFunc GinEngineRouterFunc) {
31+
setting := settings.NewSetting()
3732

38-
logging.InitLogger(os.Getenv(settings.LogLevel))
33+
Logger = logging.InitLogger(setting.LogLevel)
34+
// SugaredLogger = Logger.Sugar
3935

40-
engine := http.InitEngine(cfg, writer)
41-
if enginePatch != nil {
42-
enginePatch(engine)
43-
}
44-
http.Run(engine)
45-
app = &App{setting: cfg}
46-
}
47-
48-
func Settings() *settings.Setting {
49-
return app.setting
36+
httpEngine := newEngine(setting)
37+
engine := httpEngine.initGinEngine(routerFunc)
38+
httpEngine.serverRun(engine)
5039
}

http/http.go app/engine.go

+19-13
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,28 @@
1515
* limitations under the License.
1616
*/
1717

18-
package http
18+
package app
1919

2020
import (
2121
"fmt"
22-
"io"
2322
"net/http"
24-
"os"
2523
"time"
2624

2725
"github.com/gin-gonic/gin"
2826

29-
"github.com/acmestack/devstack/logging"
30-
"github.com/acmestack/devstack/settings"
27+
"github.com/acmestack/devstack/app/settings"
3128
)
3229

33-
func InitEngine(cfg *settings.Setting, writer io.Writer) *gin.Engine {
34-
gin.SetMode(os.Getenv(gin.EnvGinMode))
30+
type engine struct {
31+
setting *settings.Setting
32+
}
33+
34+
func newEngine(setting *settings.Setting) *engine {
35+
return &engine{setting: setting}
36+
}
37+
38+
func (e *engine) initGinEngine(routerFunc GinEngineRouterFunc) *gin.Engine {
39+
gin.SetMode(e.setting.EnvGinMode)
3540

3641
router := gin.Default()
3742

@@ -50,22 +55,23 @@ func InitEngine(cfg *settings.Setting, writer io.Writer) *gin.Engine {
5055
param.ErrorMessage,
5156
)
5257
},
53-
Output: writer,
58+
Output: e.setting.Writer,
5459
SkipPaths: nil,
5560
}))
5661

5762
// Recovery middleware recovers from any panics and writes a 500 if there was one.
5863
router.Use(gin.CustomRecovery(func(context *gin.Context, recovered interface{}) {
59-
if err, ok := recovered.(string); ok {
60-
logging.Logger.Errorf("error %v", err)
61-
context.JSON(http.StatusInternalServerError, http.StatusInternalServerError)
62-
}
63-
context.AbortWithStatus(http.StatusInternalServerError)
64+
Logger.Error(fmt.Errorf("%v", recovered), "")
65+
context.JSON(http.StatusInternalServerError, http.StatusInternalServerError)
6466
}))
6567

6668
router.GET("/health", func(c *gin.Context) {
6769
c.String(http.StatusOK, "ok")
6870
})
6971

72+
if routerFunc != nil {
73+
routerFunc(router)
74+
}
75+
7076
return router
7177
}

http/server.go app/server.go

+15-15
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,28 @@
1515
* limitations under the License.
1616
*/
1717

18-
package http
18+
package app
1919

2020
import (
2121
"net/http"
2222

2323
"github.com/gin-gonic/gin"
24-
25-
"github.com/acmestack/devstack/logging"
2624
)
2725

28-
type EnginePatchFunc func(engine *gin.Engine)
26+
type GinEngineRouterFunc func(engine *gin.Engine)
2927

30-
func Run(engine *gin.Engine) {
31-
httpServer := &http.Server{
32-
Addr: ":8080",
33-
Handler: engine,
34-
}
35-
36-
logging.Logger.Infof("start http server listening %s", httpServer.Addr)
37-
38-
err := httpServer.ListenAndServe()
39-
if err != nil {
40-
logging.Logger.Errorf("start http server error %v", err)
28+
func (e *engine) serverRun(engine *gin.Engine) {
29+
{
30+
httpServer := &http.Server{
31+
Addr: ":8080",
32+
Handler: engine,
33+
}
34+
35+
Logger.Info("start https server listening", "addr", httpServer.Addr)
36+
37+
err := httpServer.ListenAndServe()
38+
if err != nil {
39+
Logger.Error(err, "start https server error")
40+
}
4141
}
4242
}

settings/settings.go app/settings/settings.go

+21-8
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,32 @@
1717

1818
package settings
1919

20+
import (
21+
"io"
22+
"os"
23+
24+
"github.com/acmestack/godkits/gox/stringsx"
25+
"github.com/gin-gonic/gin"
26+
27+
"github.com/acmestack/devstack/logging"
28+
)
29+
2030
const (
2131
AppConfigurations = "app.yaml"
22-
LogLevel = "LOG_LEVEL"
2332
)
2433

2534
type Setting struct {
26-
path string
27-
}
28-
29-
func NewSetting(path string, patch ...interface{}) *Setting {
30-
return &Setting{path: path}
35+
LogLevel logging.LogLevel
36+
Port string
37+
Writer io.Writer
38+
EnvGinMode string
3139
}
3240

33-
func Patch(patch interface{}) interface{} {
34-
return nil
41+
func NewSetting() *Setting {
42+
return &Setting{
43+
LogLevel: logging.LogLevel(stringsx.DefaultIfEmpty(os.Getenv("LOG_LEVEL"), string(logging.LogLevelInfo))),
44+
Port: stringsx.DefaultIfEmpty(os.Getenv("PORT"), "8080"),
45+
Writer: io.MultiWriter(os.Stdout),
46+
EnvGinMode: stringsx.DefaultIfEmpty(os.Getenv(gin.EnvGinMode), "debug"),
47+
}
3548
}

go.mod

+3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ module github.com/acmestack/devstack
33
go 1.18
44

55
require (
6+
github.com/acmestack/godkits v0.0.11
67
github.com/gin-gonic/gin v1.9.0
8+
github.com/go-logr/logr v1.2.4
9+
github.com/go-logr/zapr v1.2.4
710
go.uber.org/zap v1.24.0
811
)
912

go.sum

+44-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
github.com/acmestack/godkits v0.0.11 h1:XVXn7iq60xbqOrBMUA3ktMDRDYlXA21vmwIHMxrbg2s=
2+
github.com/acmestack/godkits v0.0.11/go.mod h1:d5kiqEvQl/LpXd8VTy7PZvQ5DDiasCX+QKA3+q8fWos=
13
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
4+
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
25
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
36
github.com/bytedance/sonic v1.8.0 h1:ea0Xadu+sHlu7x5O3gKhRpQ1IKiMrSiHttPF0ybECuA=
47
github.com/bytedance/sonic v1.8.0/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U=
@@ -12,6 +15,10 @@ github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE
1215
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
1316
github.com/gin-gonic/gin v1.9.0 h1:OjyFBKICoexlu99ctXNR2gg+c5pKrKMuyjgARg9qeY8=
1417
github.com/gin-gonic/gin v1.9.0/go.mod h1:W1Me9+hsUSyj3CePGrd1/QrKJMSJ1Tu/0hFEH89961k=
18+
github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
19+
github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
20+
github.com/go-logr/zapr v1.2.4 h1:QHVo+6stLbfJmYGkQ7uGHUCu5hnAFAj6mDe6Ea0SeOo=
21+
github.com/go-logr/zapr v1.2.4/go.mod h1:FyHWQIzQORZ0QVE1BtVHv3cKtNLuXsbNLtpuhNapBOA=
1522
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
1623
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
1724
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
@@ -29,7 +36,10 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr
2936
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
3037
github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4=
3138
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
39+
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
3240
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
41+
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
42+
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
3343
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
3444
github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
3545
github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
@@ -41,10 +51,13 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
4151
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
4252
github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU=
4353
github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek=
44-
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
54+
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
55+
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
56+
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
4557
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
4658
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
4759
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
60+
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
4861
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
4962
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
5063
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
@@ -59,31 +72,60 @@ github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS
5972
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
6073
github.com/ugorji/go/codec v1.2.9 h1:rmenucSohSTiyL09Y+l2OCk+FrMxGMzho2+tjr5ticU=
6174
github.com/ugorji/go/codec v1.2.9/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
75+
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
6276
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
6377
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
6478
go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=
79+
go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
6580
go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4=
6681
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
6782
go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60=
6883
go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=
6984
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 h1:18EFjUmQOcUvxNYSkA6jO9VAiXCnxFY6NyDX0bHDmkU=
7085
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
86+
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
87+
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
7188
golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE=
7289
golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU=
90+
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
91+
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
92+
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
93+
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
94+
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
95+
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
7396
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
7497
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
98+
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
99+
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
100+
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
101+
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
102+
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
103+
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
104+
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
75105
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
76106
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
77107
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
108+
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
109+
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
110+
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
78111
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
79112
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
80-
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
113+
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
114+
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
115+
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
116+
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
117+
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
118+
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
81119
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
120+
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
121+
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
82122
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
83123
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
84124
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
85125
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
126+
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
86127
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
128+
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA=
87129
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
88130
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
89131
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

logging/level.go

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package logging
2+
3+
// LogLevel defines a log level for system logs.
4+
type LogLevel string
5+
6+
const (
7+
// LogLevelDebug defines the "debug" logging level.
8+
LogLevelDebug LogLevel = "debug"
9+
10+
// LogLevelInfo defines the "Info" logging level.
11+
LogLevelInfo LogLevel = "info"
12+
13+
// LogLevelWarn defines the "Warn" logging level.
14+
LogLevelWarn LogLevel = "warn"
15+
16+
// LogLevelError defines the "Error" logging level.
17+
LogLevelError LogLevel = "error"
18+
)

0 commit comments

Comments
 (0)