sklose / NCalc2

expression evaluator for .NET with built-in compiler
MIT License
166 stars 58 forks source link

Request mechanism to enable/disable Debug.Writeline #27

Open DaveBlakeman opened 5 years ago

DaveBlakeman commented 5 years ago

The caching mechanism writes unconditional messages to Debug.Writeline.

Debug.WriteLine("Cache entry released: " + key);
Debug.WriteLine("Expression retrieved from cache: " + expression);
Debug.WriteLine("Expression added to cache: " + expression);

Could we add a

boolean DebugLogging;

property (default = true). If DebugLogging = false, don't write these messages.

Or alternately a more general mechanism to specify

DebugVerbosity = (None, Low, Medium, High, Garrulous etc)

to allow for additional logging later.

I'm happy to do this, but wanted feedback on the preferred approach.

A bit of background as to why this matters:-

In an example I'm working with there are over 10,000 calls to Debug.WriteLine in NCalc due to cached expressions. We are using NCalc via a DLL, which itself plugs in to UnrealEngine and the SDK is swamped with these messages, making development excruciatingly slow. All solutions to remove these messages at the host end are complex and slow.

DaveBlakeman commented 5 years ago

On reflection, a better name for the property would be 'CacheLogging', to avoid any interference with any future logging needs.

cd21h commented 5 years ago

I'd recommend something like https://github.com/damianh/LibLog instead