In a high-performance file system, the calls to ILogger.Debug accounts for a significant amount of allocations. Even though the logger may ignore the messages, object[] arrays are still allocated for each call that have arguments, and every value type argument is boxed causing further allocations.
For production operation, Debug messages are usually not needed, so to avoid these allocations I am adding a ILogger.DebugEnabled property that allows the logger to declare whether it wants debug messages. If not, all the debug logging (and allocations) is skipped.
It is technically a breaking change to add a method to an existing interface that library users may be implementing. But it only affects anybody that has a custom ILoggerimplementation (the provided ones in DokanNet have been updated). But I deem this worth it over adding a new logger interface because it is so simple to update any custom logger implementations with this property.
Thanks you for the contribution! Very appreciated.
I was looking for a reason to make a new dokan-dotnet release and looks like you gave me a good one :)
In a high-performance file system, the calls to
ILogger.Debug
accounts for a significant amount of allocations. Even though the logger may ignore the messages,object[]
arrays are still allocated for each call that have arguments, and every value type argument is boxed causing further allocations.For production operation, Debug messages are usually not needed, so to avoid these allocations I am adding a
ILogger.DebugEnabled
property that allows the logger to declare whether it wants debug messages. If not, all the debug logging (and allocations) is skipped.It is technically a breaking change to add a method to an existing interface that library users may be implementing. But it only affects anybody that has a custom
ILogger
implementation (the provided ones in DokanNet have been updated). But I deem this worth it over adding a new logger interface because it is so simple to update any custom logger implementations with this property.