microsoft / infersharp

Infer# is an interprocedural and scalable static code analyzer for C#. Via the capabilities of Facebook's Infer, this tool detects null dereferences, resource leaks, and thread-safety violations. It also performs taint flow tracking to detect critical security vulnerabilities like SQL injections.
MIT License
730 stars 29 forks source link

Add Debug/Production logging levels #76

Closed aayc closed 2 years ago

aayc commented 2 years ago

Add Debug and Production logging levels to Cilsil translation component so that console warnings/errors about unknown instructions, unhandled exception-handling, etc. are omitted when running in production environment.

Production logging level is assumed unless --debug is passed as a flag to the translation command.

This change is made by adding a debug mode which omits all warnings.

xinshiMSFT commented 2 years ago

https://github.com/microsoft/infersharp/blob/2c0a707cf92b28e038e5eb32cb061b98f4498562/run_infersharp.sh#L59 and https://github.com/microsoft/infersharp/blob/2c0a707cf92b28e038e5eb32cb061b98f4498562/run_infersharp_ci.sh#L25 are probably not needed for end users since debug will be false by default.

matjin commented 2 years ago

Can you actually go ahead and use Nlog for this? It'll be much more elegant https://blog.elmah.io/nlog-tutorial-the-essential-guide-for-logging-from-csharp/

aayc commented 2 years ago

Nlog seems like the best long term solution, but how about for now we do the simple debug log suppression so that we can get this in the 1.2 release before integration with other tools? I've updated the PR for this.