logp.Logger
should expose a Close
method to close any open files
#179
Labels
Team:Elastic-Agent
Label for the Agent team
Team:Elastic-Agent-Control-Plane
Label for the Agent Control Plane team
Team:Elastic-Agent-Data-Plane
Label for the Agent Data Plane team
Currently the
logp.Logger
does not expose any API that allows for closing all open files, this causes problems on Windows making removing the directory with the open file to fail.One simple way to reproduce it is to create a test that configures
logp
to log to a file in a folder returned byt.TempDir
, when the test ends, there will be an error fromtesting.go
that the folder could not be removed.One option to work around this issue is to use
os.MkdirTemp
instead oft.TempDir
.Here is an example of a test that would fail on windows due to open files:
elastic-agent-libs/logp/core_test.go
Lines 230 to 245 in 25f61a1
The file rotator we instantiate does expose a
Close
:elastic-agent-libs/logp/core.go
Lines 242 to 252 in be95cca
elastic-agent-libs/file/rotator.go
Lines 371 to 375 in be95cca
however we do not keep a reference for it, completely losing access to it's
Close
method.The text was updated successfully, but these errors were encountered: