Skip to content

Commit

Permalink
Merge branch 'fix-logging' of github.com:containerish/OpenRegistry in…
Browse files Browse the repository at this point in the history
…to fix-logging

Signed-off-by: jay-dee7 <[email protected]>
  • Loading branch information
jay-dee7 committed Dec 12, 2021
2 parents c151b61 + 2958a49 commit c621aaa
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 44 deletions.
1 change: 0 additions & 1 deletion auth/basic_auth.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package auth

import (
// "fmt"
"encoding/base64"
"fmt"
"net/http"
Expand Down
12 changes: 0 additions & 12 deletions registry/v2/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,6 @@ func digest(bz []byte) string {
return "sha256:" + hex.EncodeToString(hash.Sum(nil))
}

//func (r *registry) debugf(lm logMsg) {
//
// if r.debug {
// r.echoLogger.Debug(lm)
// }
//
// if r.debug {
// e := r.log.Debug()
// e.Fields(lm).Send()
// }
//}

func (r *registry) getHttpUrlFromSkylink(s string) string {
link := strings.TrimPrefix(s, "sia://")
return fmt.Sprintf("https://siasky.net/%s", link)
Expand Down
3 changes: 1 addition & 2 deletions registry/v2/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ import (
"sync"
"time"

"github.com/containerish/OpenRegistry/telemetry"

"github.com/containerish/OpenRegistry/cache"
"github.com/containerish/OpenRegistry/skynet"
"github.com/containerish/OpenRegistry/telemetry"
"github.com/containerish/OpenRegistry/types"
"github.com/docker/distribution/uuid"
"github.com/labstack/echo/v4"
Expand Down
23 changes: 11 additions & 12 deletions registry/v2/types.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package registry

import (
"github.com/containerish/OpenRegistry/telemetry"
"sync"

"github.com/containerish/OpenRegistry/telemetry"

"github.com/containerish/OpenRegistry/cache"
"github.com/containerish/OpenRegistry/skynet"
fluentbit "github.com/containerish/OpenRegistry/telemetry/fluent-bit"
"github.com/labstack/echo/v4"
)

Expand Down Expand Up @@ -52,9 +52,9 @@ type RegistryErrors struct {
}

type RegistryError struct {
Detail map[string]interface{} `json:"detail,omitempty"`
Code string `json:"code"`
Message string `json:"message"`
Detail map[string]interface{} `json:"detail,omitempty"`
}

// OCI - Distribution Spec compliant Headers
Expand Down Expand Up @@ -85,21 +85,20 @@ const (

type (
registry struct {
logger telemetry.Logger
debug bool
skynet *skynet.Client
b blobs
logger telemetry.Logger
localCache cache.Store
skynet *skynet.Client
mu *sync.RWMutex
debug bool
}

blobs struct {
mutex sync.Mutex
contents map[string][]byte
uploads map[string][]byte
layers map[string][]string
fluentbit fluentbit.FluentBit
registry *registry
mutex sync.Mutex
contents map[string][]byte
uploads map[string][]byte
layers map[string][]string
registry *registry
}

logMsg map[string]interface{}
Expand Down
1 change: 0 additions & 1 deletion router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
// Register is the entry point that registers all the endpoints
// nolint
func Register(cfg *config.RegistryConfig, e *echo.Echo, reg registry.Registry, authSvc auth.Authentication, localCache cache.Store) {

e.Use(middleware.Recover())
e.Use(middleware.CORS())

Expand Down
31 changes: 15 additions & 16 deletions telemetry/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ import (
"sync"
"time"

"github.com/labstack/gommon/log"

fluentbit "github.com/containerish/OpenRegistry/telemetry/fluent-bit"
"github.com/containerish/OpenRegistry/types"
"github.com/labstack/echo/v4"
"github.com/labstack/gommon/log"
"github.com/rs/zerolog"
"github.com/valyala/fasttemplate"
)
Expand Down Expand Up @@ -318,85 +317,85 @@ func (l logger) SetHeader(h string) {
}

func (l logger) Print(i ...interface{}) {
l.zlog.WithLevel(l.zlog.GetLevel()).Msgf("%v", i)
l.zlog.WithLevel(l.zlog.GetLevel()).Msgf("%v", i...)
}

func (l logger) Printf(format string, args ...interface{}) {
l.zlog.WithLevel(l.zlog.GetLevel()).Msgf(format, args)
l.zlog.WithLevel(l.zlog.GetLevel()).Msgf(format, args...)
}

func (l logger) Printj(j log.JSON) {
l.zlog.WithLevel(l.zlog.GetLevel()).Fields(j).Send()
}

func (l logger) Debug(i ...interface{}) {
l.zlog.Debug().Msgf("%v", i)
l.zlog.Debug().Msgf("%v", i...)
}

func (l logger) Debugf(format string, args ...interface{}) {
l.zlog.Debug().Msgf(format, args)
l.zlog.Debug().Msgf(format, args...)
}

func (l logger) Debugj(j log.JSON) {
l.zlog.Debug().Fields(j).Send()
}

func (l logger) Info(i ...interface{}) {
l.zlog.Info().Msgf("%v", i)
l.zlog.Info().Msgf("%v", i...)
}

func (l logger) Infof(format string, args ...interface{}) {
l.zlog.Info().Msgf(format, args)
l.zlog.Info().Msgf(format, args...)
}

func (l logger) Infoj(j log.JSON) {
l.zlog.Info().Fields(j).Send()
}

func (l logger) Warn(i ...interface{}) {
l.zlog.Warn().Msgf("%v", i)
l.zlog.Warn().Msgf("%v", i...)
}

func (l logger) Warnf(format string, args ...interface{}) {
l.zlog.Warn().Msgf(format, args)
l.zlog.Warn().Msgf(format, args...)
}

func (l logger) Warnj(j log.JSON) {
l.zlog.Warn().Fields(j).Send()
}

func (l logger) Error(i ...interface{}) {
l.zlog.Error().Msgf("%v", i)
l.zlog.Error().Msgf("%v", i...)
}

func (l logger) Errorf(format string, args ...interface{}) {
l.zlog.Error().Msgf(format, args)
l.zlog.Error().Msgf(format, args...)
}

func (l logger) Errorj(j log.JSON) {
l.zlog.Error().Fields(j).Send()
}

func (l logger) Fatal(i ...interface{}) {
l.zlog.Fatal().Msgf("%v", i)
l.zlog.Fatal().Msgf("%v", i...)
}

func (l logger) Fatalj(j log.JSON) {
l.zlog.Fatal().Fields(j).Send()
}

func (l logger) Fatalf(format string, args ...interface{}) {
l.zlog.Fatal().Msgf(format, args)
l.zlog.Fatal().Msgf(format, args...)
}

func (l logger) Panic(i ...interface{}) {
l.zlog.Panic().Msgf("%v", i)
l.zlog.Panic().Msgf("%v", i...)
}

func (l logger) Panicj(j log.JSON) {
l.zlog.Panic().Fields(j).Send()
}

func (l logger) Panicf(format string, args ...interface{}) {
l.zlog.Panic().Msgf(format, args)
l.zlog.Panic().Msgf(format, args...)
}

0 comments on commit c621aaa

Please sign in to comment.