Log classes for MQL4 and MQL5 - Library for MetaTrader 5 | MT5 EA download
The debug logger class is a powerful and flexible logging utility designed specifically for the MQL4/5 environment. It is an essential tool for developers who need to accurately monitor, debug, and trace application behavior. Below, we will explore the main features and functionality of this class.
Here is an example of how to initialize and use the CDebugLogger class:
// Initialize the logger using INFO level logging to file CDebugLogger logger(info, true , "log.txt" , true , TIME_DATE | TIME_MINUTES , false , true , true , true ); // Log a simple message logger.log(info, "This is an info message" ); // Silence keyword logger.AddSilentKeyword( "password" ); // Log a message that will be silenced Logger.Log(info, "User entered password: 1234" ); // Enable file logging logger. Enable file logging ( True , "Debug.Log" , False ); // Remove the silent keyword logger.RemoveSilentKeyword( "Password" ); // Log a message after removing the keyword from the silent list Logger.Log(info, "User entered password: 1234" ); // Add keyword filter logger logger.AddFilterKeyword( "success" ); // Log a message that will be filtered out logger.log(info, "Operation failed" ); // Log a message that will pass the filter logger.log(info, "operation successful" ); // Remove the keyword from the filter logger.RemoveFilterKeyword( "success" ); // Use the general Log function for initialization logging.initialize(warn, true , "warning.log" , true , TIME_SECONDS , true , false , true , true ); // Use the general Log function to record warning logs (warning, "This is a warning message" );
Script example
To use the CDebugLogger class in a script, simply include the necessary libraries at the beginning of the file as follows:
For more information about the CDebugLogger class or to explore other advanced tools and solutions, please visit Baofeng Technology .
Attachment download
📎 logging.mq5 (9.08 KB)
📎 logging.mqh (44.87 KB)
Source: MQL5 #51817
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •