Skip to content

Commit

Permalink
feat: add logger in application
Browse files Browse the repository at this point in the history
Signed-off-by: ZhangJian He <[email protected]>
  • Loading branch information
shoothzj committed Nov 2, 2024
1 parent 3e30636 commit 4e9db5e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 24 deletions.
15 changes: 8 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ module github.com/opengemini/opengemini-client-go-application
go 1.20

require (
github.com/libgox/buffer v0.0.0-20241031081046-5d4932c890d4
github.com/libgox/envx v0.0.0-20241031234047-a094467ecb9f
github.com/libgox/flyway v0.0.0-20241031081155-664faf8b516f
github.com/libgox/gocollections v0.0.0-20241031081053-07bce0388f78
github.com/libgox/retry v0.0.0-20241101011336-167b47045bd9
github.com/libgox/spring-cloud-go v0.0.3-0.20241026022417-5db252b8b188
github.com/libgox/buffer v0.1.0
github.com/libgox/envx v0.1.0
github.com/libgox/flyway v0.1.0
github.com/libgox/gocollections v0.1.0
github.com/libgox/retry v0.1.0
github.com/libgox/slogsimple v0.1.0
github.com/libgox/spring-cloud-go v0.1.0
github.com/libgox/unicodex v0.0.1
github.com/protocol-laboratory/opcua-go v0.0.0-20241022080800-2ff8b0ffb7c8
golang.org/x/exp v0.0.0-20240823005443-9b4947da3948
Expand All @@ -18,7 +19,7 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/libgox/addr v0.2.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/protocol-laboratory/zookeeper-client-go v0.0.4-0.20241026020853-9929d040af36 // indirect
github.com/protocol-laboratory/zookeeper-client-go v0.1.0 // indirect
github.com/stretchr/testify v1.9.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
30 changes: 16 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,20 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4=
github.com/libgox/addr v0.2.0 h1:he4Vv7lzcGy/1qNpjJufEWRql0S23Ki/j0XpTDMDu3s=
github.com/libgox/addr v0.2.0/go.mod h1:j0hEfpRqTZy4BsstS9Egsn1U0JmNdj/VkbF2VBmJlFw=
github.com/libgox/buffer v0.0.0-20241031081046-5d4932c890d4 h1:vpGf8mO0s2GRZuWSrX1MRWVwa6l+WAmMkkW5NxOag98=
github.com/libgox/buffer v0.0.0-20241031081046-5d4932c890d4/go.mod h1:VAuNNs9Mp5NttnP8etLB4FI4ZZ67sRUnk/jTb/BnSqo=
github.com/libgox/envx v0.0.0-20241031234047-a094467ecb9f h1:JRR+kDPnQOHRuURzLT15sI7v5WZ6qA/9ePZUMyzI7Ug=
github.com/libgox/envx v0.0.0-20241031234047-a094467ecb9f/go.mod h1:tY6BqljHogxCny9PPIB8lrK4ZusVXyPGdjjPrpQBGao=
github.com/libgox/flyway v0.0.0-20241031081155-664faf8b516f h1:ORjk8aiHiZcD153peCNEXlMP6pp2QCIKMx/h/VRGybQ=
github.com/libgox/flyway v0.0.0-20241031081155-664faf8b516f/go.mod h1:mGoke7/soomn6WdAOo75552S5Y8jjjUm6zudtM/WI9I=
github.com/libgox/gocollections v0.0.0-20241031081053-07bce0388f78 h1:qMJhPfSqjFjsWk4lufbQDH2Vu1cz9E0jKRZq4jm7bxI=
github.com/libgox/gocollections v0.0.0-20241031081053-07bce0388f78/go.mod h1:Y4udpR8lStv1f67hVWbMCrcTyTvf98bFFsu/ZXvAvZ0=
github.com/libgox/retry v0.0.0-20241101011336-167b47045bd9 h1:DTnutjCJRIbTHGwpaM9vyZ2MIT808NYGtxgHtrQ5UIE=
github.com/libgox/retry v0.0.0-20241101011336-167b47045bd9/go.mod h1:LVgyTROtcSz8k/vEgtRnoMSwIXKaGY57qZymrKMpb/M=
github.com/libgox/spring-cloud-go v0.0.3-0.20241026022417-5db252b8b188 h1:KWMS8mvvtWl3pDxB7qu2SCrYkm2WsgOymRK2p59thtw=
github.com/libgox/spring-cloud-go v0.0.3-0.20241026022417-5db252b8b188/go.mod h1:0bHHFwTumvrlRwU/yWndUzI93+RJDrm6pWbZl5dNjjs=
github.com/libgox/buffer v0.1.0 h1:a1cIIX4zW+7ybY/Ys20v/HmuhTvOsi3xdewirFl6mnc=
github.com/libgox/buffer v0.1.0/go.mod h1:VAuNNs9Mp5NttnP8etLB4FI4ZZ67sRUnk/jTb/BnSqo=
github.com/libgox/envx v0.1.0 h1:K/z+MYKKu/ixLclbxUmVXuyYvvemg7CwiRbnveoKpQw=
github.com/libgox/envx v0.1.0/go.mod h1:tY6BqljHogxCny9PPIB8lrK4ZusVXyPGdjjPrpQBGao=
github.com/libgox/flyway v0.1.0 h1:Bee3grCFVKzV+S3tvQDCQMVQqirekEttNXMiiSuZDUc=
github.com/libgox/flyway v0.1.0/go.mod h1:mGoke7/soomn6WdAOo75552S5Y8jjjUm6zudtM/WI9I=
github.com/libgox/gocollections v0.1.0 h1:uTvbl5SqayPgN9LDMeXD1QCU5mHNAwgtHc3Ktg7JiUA=
github.com/libgox/gocollections v0.1.0/go.mod h1:Y4udpR8lStv1f67hVWbMCrcTyTvf98bFFsu/ZXvAvZ0=
github.com/libgox/retry v0.1.0 h1:fNYUskjoFARnpWxaarQZfIv5wLZ+BM1qebEnAXH8R1U=
github.com/libgox/retry v0.1.0/go.mod h1:LQ3ivFBJelpV/nuuwxsf5KiLwORL+LaBIYrgnaDxyCo=
github.com/libgox/slogsimple v0.1.0 h1:q9juFCzY9ExrBAmO+wRwapR+KAkxnk3gMVjmWFNts5k=
github.com/libgox/slogsimple v0.1.0/go.mod h1:hZPb6cYomHqLPXr9EcDcGumvHZtM1HROZJlPvHEPXCA=
github.com/libgox/spring-cloud-go v0.1.0 h1:As74b4L13f1Gq/GVhGaaNyRbAejCHr9sjixxyYynY2k=
github.com/libgox/spring-cloud-go v0.1.0/go.mod h1:I/UkhEG7efWMZR4/oZNhVFEzbnCE+CW1dFHFkTZqCCI=
github.com/libgox/unicodex v0.0.1 h1:yUuZWMVXC5N9dcYgIc3aO7+2M5jN+XVatrU08Y5fC4k=
github.com/libgox/unicodex v0.0.1/go.mod h1:RaB9wNp/oOS0Ew5+Wml7WePjztZ3njXiNid08KOmgjs=
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=
Expand All @@ -54,8 +56,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw=
github.com/protocol-laboratory/opcua-go v0.0.0-20241022080800-2ff8b0ffb7c8 h1:G6dNiZGs7jmjiL3nRcAaoWsrkteeLnBDqPwkOgUVC2g=
github.com/protocol-laboratory/opcua-go v0.0.0-20241022080800-2ff8b0ffb7c8/go.mod h1:pK+CGt9aKG68k0c4MWCvwF9dpyObrcxK9J8PIUwn2h0=
github.com/protocol-laboratory/zookeeper-client-go v0.0.4-0.20241026020853-9929d040af36 h1:O9iIJjCwLXOAK4lSHghHcfH3HKc+RuzNTUP1+xdfR2w=
github.com/protocol-laboratory/zookeeper-client-go v0.0.4-0.20241026020853-9929d040af36/go.mod h1:UKYaKMjuO6NNZXHEn5wH+OyKm5LVH28rjs4Zx/htNc8=
github.com/protocol-laboratory/zookeeper-client-go v0.1.0 h1:jgWXuhr/AswgQqPxfObKnvPRQCe30/5+QoL2RVyfzOk=
github.com/protocol-laboratory/zookeeper-client-go v0.1.0/go.mod h1:UKYaKMjuO6NNZXHEn5wH+OyKm5LVH28rjs4Zx/htNc8=
github.com/shirou/gopsutil/v3 v3.23.12 h1:z90NtUkp3bMtmICZKpC4+WaknU1eXtp5vtbQ11DgpE4=
github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
Expand Down
16 changes: 13 additions & 3 deletions pkg/boot/boot.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,25 @@ package boot

import (
"github.com/libgox/envx"
"github.com/libgox/slogsimple"
"golang.org/x/exp/slog"
"os"
)

type ClientApplication struct {
type Application struct {
logger *slog.Logger
}

func NewClientApplication() *ClientApplication {
func NewTestClientApplication() *Application {
logger := slog.Default()
envx.GetStrOr("POD_NAME", "defaultName")
logger.Info("Starting client application")
return &ClientApplication{}
return &Application{}
}

func (a *Application) Boot() {
a.logger = slog.New(slogsimple.NewHandler(&slogsimple.Config{
Output: os.Stdout,
MinLevel: slog.LevelInfo,
}))
}

0 comments on commit 4e9db5e

Please sign in to comment.