Closed blindpirate closed 1 year ago
Interesting. For me, the original was the expected behaviour. Maybe we need to print both open & close.
With the "expected" behavior, it's difficult to track when a file is closed - the "open" stacktrace is printed at the "close" point. I strongly recommend changing to this PR's behaviour because it's really helpful in my practice.
Thanks, please help me understand your practice a bit more.
My case was that in a large application there're some file handler leaks. I applied this library to my application and printed all open/close log to a file. When analyzing the log file, I noticed that I couldn't find out where the files were closed - for example, you see a file opened twice but only closed once, and the close()
code can be invoked in two (or more) places, without closing stacktrace I can't understand where it's closed and where it's not closed.
Hope this makes sense.
That makes total sense, thank you!!
Closing in favor of #132
Previously when a file close callback is invoked, the dumped trace is not the closing stacktrace, but the opening stacktrace. This PR fixes this issue by creating a new FileRecord instance.