@@ -34,10 +34,10 @@ func init() {
3434 minimumCallerDepth = 1
3535}
3636
37- // Defines the key when adding errors using WithError.
37+ // ErrorKey defines the key when adding errors using [ WithError], [Logger.WithError] .
3838var ErrorKey = "error"
3939
40- // An entry is the final or intermediate Logrus logging entry. It contains all
40+ // Entry is the final or intermediate Logrus logging entry. It contains all
4141// the fields passed with WithField{,s}. It's finally logged when Trace, Debug,
4242// Info, Warn, Error, Fatal or Panic is called on it. These objects can be
4343// reused and passed around as much as you wish to avoid field duplication.
@@ -88,12 +88,12 @@ func (entry *Entry) Dup() *Entry {
8888 return & Entry {Logger : entry .Logger , Data : data , Time : entry .Time , Context : entry .Context , err : entry .err }
8989}
9090
91- // Returns the bytes representation of this entry from the formatter.
91+ // Bytes returns the bytes representation of this entry from the formatter.
9292func (entry * Entry ) Bytes () ([]byte , error ) {
9393 return entry .Logger .Formatter .Format (entry )
9494}
9595
96- // Returns the string representation from the reader and ultimately the
96+ // String returns the string representation from the reader and ultimately the
9797// formatter.
9898func (entry * Entry ) String () (string , error ) {
9999 serialized , err := entry .Bytes ()
@@ -104,12 +104,13 @@ func (entry *Entry) String() (string, error) {
104104 return str , nil
105105}
106106
107- // Add an error as single field (using the key defined in ErrorKey) to the Entry.
107+ // WithError adds an error as single field (using the key defined in [ErrorKey])
108+ // to the Entry.
108109func (entry * Entry ) WithError (err error ) * Entry {
109110 return entry .WithField (ErrorKey , err )
110111}
111112
112- // Add a context to the Entry.
113+ // WithContext adds a context to the Entry.
113114func (entry * Entry ) WithContext (ctx context.Context ) * Entry {
114115 dataCopy := make (Fields , len (entry .Data ))
115116 for k , v := range entry .Data {
@@ -118,12 +119,12 @@ func (entry *Entry) WithContext(ctx context.Context) *Entry {
118119 return & Entry {Logger : entry .Logger , Data : dataCopy , Time : entry .Time , err : entry .err , Context : ctx }
119120}
120121
121- // Add a single field to the Entry.
122+ // WithField adds a single field to the Entry.
122123func (entry * Entry ) WithField (key string , value interface {}) * Entry {
123124 return entry .WithFields (Fields {key : value })
124125}
125126
126- // Add a map of fields to the Entry.
127+ // WithFields adds a map of fields to the Entry.
127128func (entry * Entry ) WithFields (fields Fields ) * Entry {
128129 data := make (Fields , len (entry .Data )+ len (fields ))
129130 for k , v := range entry .Data {
@@ -152,7 +153,7 @@ func (entry *Entry) WithFields(fields Fields) *Entry {
152153 return & Entry {Logger : entry .Logger , Data : data , Time : entry .Time , err : fieldErr , Context : entry .Context }
153154}
154155
155- // Overrides the time of the Entry.
156+ // WithTime overrides the time of the Entry.
156157func (entry * Entry ) WithTime (t time.Time ) * Entry {
157158 dataCopy := make (Fields , len (entry .Data ))
158159 for k , v := range entry .Data {
@@ -434,7 +435,7 @@ func (entry *Entry) Panicln(args ...interface{}) {
434435 entry .Logln (PanicLevel , args ... )
435436}
436437
437- // Sprintlnn => Sprint no newline. This is to get the behavior of how
438+ // sprintlnn => Sprint no newline. This is to get the behavior of how
438439// fmt.Sprintln where spaces are always added between operands, regardless of
439440// their type. Instead of vendoring the Sprintln implementation to spare a
440441// string allocation, we do the simplest thing.
0 commit comments