Libraries: Simplest Logger class for MetaTrader 5

 

Simplest Logger class for MetaTrader 5:

The simplest class for logging in MetaTrader 5 with support for levels, message format, include and exclude filters on substrings.

Simplest Logger class for MetaTrader 5

Author: Denis Kislicyn

 

Add a SetDebugMode method to set the desired logging level (e.g. DEBUG or INFO).

Also add an IsDebugEnabled method which simply returns a bool indicating whether debug mode is active.


Unique configuration:

In your OnInit function, call SetDebugMode only once.

Then store the result of IsDebugEnabled in a global variable, for example g_debug, for quick access.


Use in your code:

Anywhere you want to log a message, add a simple if condition that checks the global g_debug. This check is extremely fast and ensures that the StringFormat is not called unnecessarily.