I need to log relatively heavy JSON data within the web request handler. Does the logrus use blocking I/O? Should I call the logger.WithFields(fields).Info(heavy_message)
in a separate goroutine?
Asked
Active
Viewed 526 times
1

Serj Piskunov
- 33
- 5
-
Is there a reason you have in mind to do so? – Adrian Nov 17 '21 at 17:02
-
Well, I think if the logrus uses blocking I/O, the execution flow will be waiting until all data is sent to the buffer. – Serj Piskunov Nov 17 '21 at 17:20
-
1That's true, but I'm not sure why it's relevant - have you observed and measured a performance problem caused by logging? – Adrian Nov 17 '21 at 18:13
-
"Does it use blocking I/O" is hardly an "opinion-based" question, bizarre. – Ed Randall Nov 18 '22 at 09:12
1 Answers
1
https://github.com/sirupsen/logrus/blob/79c5ab66aa2ce7d9ff7b3c437ebc22fcc519a967/entry.go#L221-L262 it looks like it is blocking i/o, so yes - you should call it in a goroutine.

Armatorix
- 1,083
- 10
- 23