Skip to content
This repository has been archived by the owner on Mar 29, 2020. It is now read-only.

Commit

Permalink
added logging standards, closes #1
Browse files Browse the repository at this point in the history
  • Loading branch information
cezarmathe committed Mar 28, 2019
1 parent 57e87de commit 966afcf
Showing 1 changed file with 46 additions and 2 deletions.
48 changes: 46 additions & 2 deletions docs/CODING_STANDARDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func function() {
}
```

- Logging
- Logging in general

Functions that start other functions(or processes) should log the start & end events themselves, and delegate the rest of the logging to the called function.

Expand Down Expand Up @@ -49,4 +49,48 @@ func (recorder *Recorder) Record() bool {
}
return true
}
```
```

- Logging level standards

- Trace level

Simple and straightforward verbose messages

```go
log.Trace("this is a trace message")
```

- Debug level

Logging should report the caller

```go
log.SetReportCaller(true)
log.Debug("function called")
```

- Info level

Meaningful messages that the end user should receive.

```go
log.Info("finished the process")
```

- Warn level

Warn level should use `.WithError(err)` is there is an error that can be handled or should be ignored.

```go
log.WithError(err).Warn("encountered an error when doing something")
```

- Error level

Error level should use `.WithError(err)` is there is an error that cannot be ignored.

```go
log.WithError(err).Error("encountered an error when doing something")
```

0 comments on commit 966afcf

Please sign in to comment.