You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi folks,
I'd like to add a field to my logging context after I have some relevant information, I've supplied the peudocode of what I'd like to do. Looking over the code in log/entry.go, this should be pretty straightforward, however it seems like a conscience decision to not allow modification to the Entry structs field variable. Instead, similar functions (i.e WithField) require the building of a new Entry entirely.
Why is the Entry struct immutable in this way?
func DownloadFile() (int) {
// Off to the network we go
}
func main() {
ctx := log.WithFields(log.Fields{
"module": "main",
})
defer ctx.Info("Download complete")
bytesDownloaded := DownloadFile()
ctx.AddField("downloadSize", bytesDownloaded)
}
The text was updated successfully, but these errors were encountered:
Hi folks,
I'd like to add a field to my logging context after I have some relevant information, I've supplied the peudocode of what I'd like to do. Looking over the code in log/entry.go, this should be pretty straightforward, however it seems like a conscience decision to not allow modification to the Entry structs field variable. Instead, similar functions (i.e WithField) require the building of a new Entry entirely.
Why is the Entry struct immutable in this way?
The text was updated successfully, but these errors were encountered: