forked from caarlos0/log
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
51 additions
and
9 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 |
---|---|---|
|
@@ -18,13 +18,15 @@ type Entry struct { | |
Fields Fields `json:"fields"` | ||
Level Level `json:"level"` | ||
Message string `json:"message"` | ||
Padding int | ||
fields []Fields | ||
} | ||
|
||
// NewEntry returns a new entry for `log`. | ||
func NewEntry(log *Logger) *Entry { | ||
return &Entry{ | ||
Logger: log, | ||
Logger: log, | ||
Padding: log.Padding, | ||
} | ||
} | ||
|
||
|
@@ -49,8 +51,9 @@ func (e *Entry) WithFields(fields Fielder) *Entry { | |
f = append(f, e.fields...) | ||
f = append(f, fields.Fields()) | ||
return &Entry{ | ||
Logger: e.Logger, | ||
fields: f, | ||
Logger: e.Logger, | ||
Padding: e.Padding, | ||
fields: f, | ||
} | ||
} | ||
|
||
|
@@ -77,6 +80,12 @@ func (e *Entry) WithError(err error) *Entry { | |
return ctx | ||
} | ||
|
||
// WithoutPadding returns entry without padding set to false. | ||
func (e *Entry) WithoutPadding() *Entry { | ||
e.Padding = defaultPadding | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
bep
|
||
return e | ||
} | ||
|
||
// Debug level message. | ||
func (e *Entry) Debug(msg string) { | ||
e.Logger.log(DebugLevel, e, msg) | ||
|
@@ -146,6 +155,7 @@ func (e *Entry) finalize(level Level, msg string) *Entry { | |
return &Entry{ | ||
Logger: e.Logger, | ||
Fields: e.mergedFields(), | ||
Padding: e.Padding, | ||
Level: level, | ||
Message: msg, | ||
} | ||
|
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
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
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
I suspect people would expect a copy of e here.