Skip to content

Commit

Permalink
Added trace log level.
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim Korolyov authored and Loren Osborn committed Oct 18, 2018
1 parent c7a33dc commit ef9d84e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,10 @@ A list of currently known of service hook can be found in this wiki [page](https

#### Level logging

Logrus has six logging levels: Debug, Info, Warning, Error, Fatal and Panic.
Logrus has seven logging levels: Trace, Debug, Info, Warning, Error, Fatal and Panic.

```go
log.Trace("Something very low level.")
log.Debug("Useful debugging information.")
log.Info("Something noteworthy happened!")
log.Warn("You should probably take a look at this.")
Expand Down
34 changes: 17 additions & 17 deletions entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ func init() {
var ErrorKey = "error"

// An entry is the final or intermediate Logrus logging entry. It contains all
// the fields passed with WithField{,s}. It's finally logged when Debug, Info,
// Warn, Error, Fatal or Panic is called on it. These objects can be reused and
// passed around as much as you wish to avoid field duplication.
// the fields passed with WithField{,s}. It's finally logged when Trace, Debug,
// Info, Warn, Error, Fatal or Panic is called on it. These objects can be
// reused and passed around as much as you wish to avoid field duplication.
type Entry struct {
Logger *Logger

Expand All @@ -35,11 +35,11 @@ type Entry struct {
// Time at which the log entry was created
Time time.Time

// Level the log entry was logged at: Debug, Info, Warn, Error, Fatal or Panic
// Level the log entry was logged at: Trace, Debug, Info, Warn, Error, Fatal or Panic
// This field will be set on entry firing and the value will be equal to the one in Logger struct field.
Level Level

// Message passed to Debug, Info, Warn, Error, Fatal or Panic
// Message passed to Trace, Debug, Info, Warn, Error, Fatal or Panic
Message string

// When formatter is called in entry.log(), a Buffer may be set to entry
Expand Down Expand Up @@ -162,18 +162,18 @@ func (entry *Entry) write() {
}
}

func (entry *Entry) Debug(args ...interface{}) {
if entry.Logger.IsLevelEnabled(DebugLevel) {
entry.log(DebugLevel, fmt.Sprint(args...))
}
}

func (entry *Entry) Trace(args ...interface{}) {
if entry.Logger.IsLevelEnabled(TraceLevel) {
entry.log(TraceLevel, fmt.Sprint(args...))
}
}

func (entry *Entry) Debug(args ...interface{}) {
if entry.Logger.IsLevelEnabled(DebugLevel) {
entry.log(DebugLevel, fmt.Sprint(args...))
}
}

func (entry *Entry) Print(args ...interface{}) {
entry.Info(args...)
}
Expand Down Expand Up @@ -216,18 +216,18 @@ func (entry *Entry) Panic(args ...interface{}) {

// Entry Printf family functions

func (entry *Entry) Debugf(format string, args ...interface{}) {
if entry.Logger.IsLevelEnabled(DebugLevel) {
entry.Debug(fmt.Sprintf(format, args...))
}
}

func (entry *Entry) Tracef(format string, args ...interface{}) {
if entry.Logger.IsLevelEnabled(TraceLevel) {
entry.Trace(fmt.Sprintf(format, args...))
}
}

func (entry *Entry) Debugf(format string, args ...interface{}) {
if entry.Logger.IsLevelEnabled(DebugLevel) {
entry.Debug(fmt.Sprintf(format, args...))
}
}

func (entry *Entry) Infof(format string, args ...interface{}) {
if entry.Logger.IsLevelEnabled(InfoLevel) {
entry.Info(fmt.Sprintf(format, args...))
Expand Down
3 changes: 1 addition & 2 deletions logrus.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ const (
InfoLevel
// DebugLevel level. Usually only enabled when debugging. Very verbose logging.
DebugLevel
// TraceLevel level. Usually only enabled when debugging. Very verbose logging.
// Usually reserved for message traces.
// TraceLevel level. Designates finer-grained informational events than the Debug.
TraceLevel
)

Expand Down

0 comments on commit ef9d84e

Please sign in to comment.