I inherited a codebase with tens of thousands of lines, and several libraries, that prints out several lines of garbage (both from normal functions and imported libraries, as well as from test functions and libraries) onto the console when I run a go test
. This makes testing a nightmare since my print statements and errors get lost in a sea of junk.
Is there an easy way to identify and output the filenames and line numbers where any sort of printing to the console occurs, so that I can mute these suckers?
Maybe adding some instrumentation to your legacy code could help.
For instance,
spacemonkeygo/monkit
can add trace graphs for you to at least identify from where those logs are generated.If the messages are printed using the
log
package, you could tell it to always include the full file path and line number where the calls happen: