Merge pull request #1231 from sirupsen/dbd-cleanup

cleanup
This commit is contained in:
David Bariod 2021-02-17 17:48:57 +01:00 committed by GitHub
commit d59e5619da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 13 deletions

View File

@ -1,4 +1,11 @@
# 1.8.0
Correct versioning number replacing v1.7.1.
# 1.7.1 # 1.7.1
Beware this release has introduced a new public API and its semver is therefore incorrect.
Code quality: Code quality:
* use go 1.15 in travis * use go 1.15 in travis
* use magefile as task runner * use magefile as task runner

View File

@ -88,10 +88,6 @@ func (entry *Entry) Dup() *Entry {
// Returns the bytes representation of this entry from the formatter. // Returns the bytes representation of this entry from the formatter.
func (entry *Entry) Bytes() ([]byte, error) { func (entry *Entry) Bytes() ([]byte, error) {
return entry.bytes_nolock()
}
func (entry *Entry) bytes_nolock() ([]byte, error) {
return entry.Logger.Formatter.Format(entry) return entry.Logger.Formatter.Format(entry)
} }
@ -222,8 +218,6 @@ func (entry Entry) HasCaller() (has bool) {
entry.Caller != nil entry.Caller != nil
} }
// This function is not declared with a pointer value because otherwise
// race conditions will occur when using multiple goroutines
func (entry *Entry) log(level Level, msg string) { func (entry *Entry) log(level Level, msg string) {
var buffer *bytes.Buffer var buffer *bytes.Buffer
@ -279,13 +273,11 @@ func (entry *Entry) write() {
fmt.Fprintf(os.Stderr, "Failed to obtain reader, %v\n", err) fmt.Fprintf(os.Stderr, "Failed to obtain reader, %v\n", err)
return return
} }
func() {
entry.Logger.mu.Lock() entry.Logger.mu.Lock()
defer entry.Logger.mu.Unlock() defer entry.Logger.mu.Unlock()
if _, err := entry.Logger.Out.Write(serialized); err != nil { if _, err := entry.Logger.Out.Write(serialized); err != nil {
fmt.Fprintf(os.Stderr, "Failed to write to log, %v\n", err) fmt.Fprintf(os.Stderr, "Failed to write to log, %v\n", err)
} }
}()
} }
func (entry *Entry) Log(level Level, args ...interface{}) { func (entry *Entry) Log(level Level, args ...interface{}) {