Skip to content

Commit

Permalink
replace log with core log
Browse files Browse the repository at this point in the history
  • Loading branch information
aajkl committed Jun 29, 2024
1 parent 40d5d82 commit 5f9b836
Show file tree
Hide file tree
Showing 17 changed files with 42 additions and 339 deletions.
13 changes: 11 additions & 2 deletions cmd/vmihub/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ import (
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
"github.com/go-playground/validator/v10"
"github.com/projecteru2/core/log"
"github.com/projecteru2/core/types"
"github.com/projecteru2/vmihub/config"
"github.com/projecteru2/vmihub/internal/api"
"github.com/projecteru2/vmihub/internal/log"
"github.com/projecteru2/vmihub/internal/models"
storFact "github.com/projecteru2/vmihub/internal/storage/factory"
"github.com/projecteru2/vmihub/internal/utils"
Expand Down Expand Up @@ -83,7 +84,15 @@ func runServer(_ *cli.Context) error {
ctx, cancel := signal.NotifyContext(context.TODO(), syscall.SIGINT, syscall.SIGTERM)
defer cancel()

if err := log.SetupLog(ctx, &cfg.Log); err != nil {
logCfg := &types.ServerLogConfig{
Level: cfg.Log.Level,
UseJSON: cfg.Log.UseJSON,
Filename: cfg.Log.Filename,
MaxSize: cfg.Log.MaxSize,
MaxAge: cfg.Log.MaxAge,
MaxBackups: cfg.Log.MaxBackups,
}
if err := log.SetupLog(ctx, logCfg, cfg.Log.SentryDSN); err != nil {
zerolog.Fatal().Err(err).Send()
}
defer log.SentryDefer()
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ require (
github.com/panjf2000/ants/v2 v2.7.3
github.com/pelletier/go-toml v1.9.5
github.com/pkg/errors v0.9.1
github.com/projecteru2/core v0.0.0-20240614132727-08e4fbc219d1
github.com/rbcervilla/redisstore/v9 v9.0.0
github.com/redis/go-redis/v9 v9.5.1
github.com/rs/zerolog v1.30.0
Expand Down Expand Up @@ -76,7 +77,7 @@ require (
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect
github.com/gorilla/context v1.1.2 // indirect
Expand Down
8 changes: 6 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/gomodule/redigo v2.0.0+incompatible h1:K/R+8tc58AaqLkqG2Ol3Qk+DR/TlNuhuh457pBFPtt0=
github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
Expand Down Expand Up @@ -247,6 +247,8 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/projecteru2/core v0.0.0-20240614132727-08e4fbc219d1 h1:ckh4IsnppXEbe9vb3Au4lKO5Z7ZNqanNBLdWViBdvxI=
github.com/projecteru2/core v0.0.0-20240614132727-08e4fbc219d1/go.mod h1:JDOLwVw4EdLTk+bqI/LdU4Ix/Wl6BaaHMzaOO5vpU8U=
github.com/rbcervilla/redisstore/v9 v9.0.0 h1:wOPbBaydbdxzi1gTafDftCI/Z7vnsXw0QDPCuhiMG0g=
github.com/rbcervilla/redisstore/v9 v9.0.0/go.mod h1:q/acLpoKkTZzIsBYt0R4THDnf8W/BH6GjQYvxDSSfdI=
github.com/redis/go-redis/v9 v9.0.3/go.mod h1:WqMKv5vnQbRuZstUwxQI195wHy+t4PuXDOjzMvcuQHk=
Expand Down Expand Up @@ -320,6 +322,8 @@ go.etcd.io/bbolt v1.3.8 h1:xs88BrvEv273UsB79e0hcVrlUWmS0a8upikMFhSyAtA=
go.etcd.io/bbolt v1.3.8/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw=
go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA=
go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60=
go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/arch v0.7.0 h1:pskyeJh/3AmoQ8CPE95vxHLqp1G1GfGNXTmcl9NEKTc=
golang.org/x/arch v0.7.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
Expand Down
2 changes: 1 addition & 1 deletion internal/api/image/chunk.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (
"github.com/gin-gonic/gin/binding"
"github.com/mcuadros/go-defaults"

"github.com/projecteru2/core/log"
"github.com/projecteru2/vmihub/internal/common"
"github.com/projecteru2/vmihub/internal/log"
"github.com/projecteru2/vmihub/internal/models"
storFact "github.com/projecteru2/vmihub/internal/storage/factory"
stotypes "github.com/projecteru2/vmihub/internal/storage/types"
Expand Down
2 changes: 1 addition & 1 deletion internal/api/image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"sync"
"sync/atomic"

"github.com/projecteru2/core/log"
"github.com/projecteru2/vmihub/internal/common"
"github.com/projecteru2/vmihub/internal/log"
storFact "github.com/projecteru2/vmihub/internal/storage/factory"
storTypes "github.com/projecteru2/vmihub/internal/storage/types"

Expand Down
2 changes: 1 addition & 1 deletion internal/api/image/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"github.com/dustin/go-humanize"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
"github.com/projecteru2/core/log"
"github.com/projecteru2/vmihub/internal/common"
"github.com/projecteru2/vmihub/internal/log"
"github.com/projecteru2/vmihub/internal/models"
"github.com/projecteru2/vmihub/internal/utils"
"github.com/projecteru2/vmihub/pkg/terrors"
Expand Down
2 changes: 1 addition & 1 deletion internal/api/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
"github.com/dgrijalva/jwt-go"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
"github.com/projecteru2/core/log"
"github.com/projecteru2/vmihub/config"
"github.com/projecteru2/vmihub/internal/common"
"github.com/projecteru2/vmihub/internal/log"
"github.com/projecteru2/vmihub/internal/middlewares"
"github.com/projecteru2/vmihub/internal/models"
"github.com/projecteru2/vmihub/internal/utils"
Expand Down
2 changes: 1 addition & 1 deletion internal/common/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"net/http"

"github.com/gin-gonic/gin"
"github.com/projecteru2/vmihub/internal/log"
"github.com/projecteru2/core/log"
"github.com/projecteru2/vmihub/internal/models"
"github.com/projecteru2/vmihub/pkg/terrors"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/common/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"github.com/cockroachdb/errors"
"github.com/gin-contrib/sessions"
"github.com/gin-gonic/gin"
"github.com/projecteru2/core/log"
"github.com/projecteru2/vmihub/config"
"github.com/projecteru2/vmihub/internal/log"
"github.com/projecteru2/vmihub/internal/models"
"github.com/projecteru2/vmihub/pkg/terrors"
)
Expand Down
78 changes: 0 additions & 78 deletions internal/log/field.go

This file was deleted.

62 changes: 0 additions & 62 deletions internal/log/inner.go

This file was deleted.

108 changes: 0 additions & 108 deletions internal/log/log.go

This file was deleted.

Loading

0 comments on commit 5f9b836

Please sign in to comment.