Skip to content

Commit

Permalink
Added JSON logging
Browse files Browse the repository at this point in the history
Signed-off-by: Vishal Rana <[email protected]>
  • Loading branch information
vishr committed Jun 9, 2016
1 parent 6783909 commit f4088cf
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
4 changes: 2 additions & 2 deletions echo.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ func (e *Echo) SetLogOutput(w io.Writer) {
e.logger.SetOutput(w)
}

// SetLogLevel sets the log level for the logger. Default value `3` (ERROR).
func (e *Echo) SetLogLevel(l uint8) {
// SetLogLevel sets the log level for the logger. Default value ERROR.
func (e *Echo) SetLogLevel(l glog.Lvl) {
e.logger.SetLevel(l)
}

Expand Down
10 changes: 5 additions & 5 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions log/logger.go
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
package log

import "io"
import (
"io"

"github.com/labstack/gommon/log"
)

type (
// Logger defines the logging interface.
Logger interface {
SetOutput(io.Writer)
SetLevel(uint8)
SetLevel(log.Lvl)
Print(...interface{})
Printf(string, ...interface{})
Printj(log.JSON)
Debug(...interface{})
Debugf(string, ...interface{})
Debugj(log.JSON)
Info(...interface{})
Infof(string, ...interface{})
Infoj(log.JSON)
Warn(...interface{})
Warnf(string, ...interface{})
Warnj(log.JSON)
Error(...interface{})
Errorf(string, ...interface{})
Errorj(log.JSON)
Fatal(...interface{})
Fatalj(log.JSON)
Fatalf(string, ...interface{})
}
)
4 changes: 1 addition & 3 deletions middleware/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package middleware

import (
"bytes"
"fmt"
"io"
"net"
"os"
Expand Down Expand Up @@ -158,9 +157,8 @@ func LoggerWithConfig(config LoggerConfig) echo.MiddlewareFunc {
return w.Write([]byte(b))
case "tx_bytes":
return w.Write([]byte(strconv.FormatInt(res.Size(), 10)))
default:
return w.Write([]byte(fmt.Sprintf("[unknown tag %s]", tag)))
}
return 0, nil
})
if err == nil {
config.Output.Write(buf.Bytes())
Expand Down

0 comments on commit f4088cf

Please sign in to comment.