-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add field logger to avoid locking.
Also use a byte buffer pool instead of holding the buffer.
- Loading branch information
Showing
3 changed files
with
92 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package logf | ||
|
||
type FieldLogger struct { | ||
fields Fields | ||
logger *Logger | ||
} | ||
|
||
func (l *FieldLogger) Debug(msg string) { | ||
l.logger.handleLog(msg, DebugLevel, l.fields) | ||
} | ||
|
||
// Info emits a info log line. | ||
func (l *FieldLogger) Info(msg string) { | ||
l.logger.handleLog(msg, InfoLevel, l.fields) | ||
} | ||
|
||
// Warn emits a warning log line. | ||
func (l *FieldLogger) Warn(msg string) { | ||
l.logger.handleLog(msg, WarnLevel, l.fields) | ||
} | ||
|
||
// Error emits an error log line. | ||
func (l *FieldLogger) Error(msg string) { | ||
l.logger.handleLog(msg, ErrorLevel, l.fields) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters