Skip to content

Commit

Permalink
code and comments clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
David Bariod committed Feb 16, 2021
1 parent 15ca3c0 commit 5cb4bf6
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions entry.go
Expand Up @@ -88,10 +88,6 @@ func (entry *Entry) Dup() *Entry {

// Returns the bytes representation of this entry from the formatter.
func (entry *Entry) Bytes() ([]byte, error) {
return entry.bytes_nolock()
}

func (entry *Entry) bytes_nolock() ([]byte, error) {
return entry.Logger.Formatter.Format(entry)
}

Expand Down Expand Up @@ -222,8 +218,6 @@ func (entry Entry) HasCaller() (has bool) {
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) {
var buffer *bytes.Buffer

Expand Down Expand Up @@ -279,13 +273,11 @@ func (entry *Entry) write() {
fmt.Fprintf(os.Stderr, "Failed to obtain reader, %v\n", err)
return
}
func() {
entry.Logger.mu.Lock()
defer entry.Logger.mu.Unlock()
if _, err := entry.Logger.Out.Write(serialized); err != nil {
fmt.Fprintf(os.Stderr, "Failed to write to log, %v\n", err)
}
}()
entry.Logger.mu.Lock()
defer entry.Logger.mu.Unlock()
if _, err := entry.Logger.Out.Write(serialized); err != nil {
fmt.Fprintf(os.Stderr, "Failed to write to log, %v\n", err)
}
}

func (entry *Entry) Log(level Level, args ...interface{}) {
Expand Down

0 comments on commit 5cb4bf6

Please sign in to comment.