Skip to content

Commit

Permalink
Fixed logger interface
Browse files Browse the repository at this point in the history
Signed-off-by: Vishal Rana <[email protected]>
  • Loading branch information
vishr committed Jun 4, 2019
1 parent 41215b3 commit 4347fba
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ type (
mutex sync.Mutex
}

Lvl uint8

JSON map[string]interface{}
)

Expand Down Expand Up @@ -108,12 +110,12 @@ func (l *Logger) SetPrefix(p string) {
l.prefix = p
}

func (l *Logger) Level() uint32 {
return atomic.LoadUint32(&l.level)
func (l *Logger) Level() Lvl {
return Lvl(atomic.LoadUint32(&l.level))
}

func (l *Logger) SetLevel(level uint32) {
atomic.StoreUint32(&l.level, level)
func (l *Logger) SetLevel(level Lvl) {
atomic.StoreUint32(&l.level, uint32(level))
}

func (l *Logger) Output() io.Writer {
Expand Down Expand Up @@ -242,11 +244,11 @@ func SetPrefix(p string) {
global.SetPrefix(p)
}

func Level() uint32 {
func Level() Lvl {
return global.Level()
}

func SetLevel(level uint32) {
func SetLevel(level Lvl) {
global.SetLevel(level)
}

Expand Down

1 comment on commit 4347fba

@duy-nguyen-dth
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
Sorry to jump in. But seem you need to change this too to make echo work

# github.com/labstack/echo
/go/src/github.com/labstack/echo/echo.go:305:19: cannot use "github.com/labstack/gommon/log".ERROR (type uint32) as type "github.com/labstack/gommon/log".Lvl in argument to e.Logger.SetLevel
/go/src/github.com/labstack/echo/echo.go:687:20: cannot use "github.com/labstack/gommon/log".DEBUG (type uint32) as type "github.com/labstack/gommon/log".Lvl in argument to e.Logger.SetLevel
const (
	DEBUG uint32 = iota + 1
	INFO
	WARN
	ERROR
	OFF
	panicLevel
	fatalLevel
)

Please sign in to comment.