I read your "Best Logging Class" name, which attracted my attention. "Best" is placing the level quite high, so I was curious to check that. I will avoid to talk about the details, as it's a freely distributed code which requires to be indulgent.
Usage and features :
- Your hidden keywords idea is good. The implementation is weak though (See below). And it will silent too much messages, for example if I am using logging. AddSilentKeyword("start"), it will filter a log using "started" or "starting", which is really not what I would expect from a "keyword" filtering.
- The rest are very basic features. For example, as core of MQL are event driven, it's a must for a log system to avoid flooding the log with repeated same entry, which can happen easily with a Log() placed in a OnTick(), OnTimer() or OnChartEvent().
From a coding point of view :
- Your constructor and your Initialize() are duplicated code for the essential parts.
- Your IsMessageSilent() is using a loop check for each word of the m_silent_keywords[] and inside this loop you convert the 'keywords' to lower case. On each log ! It's really inefficient.
- Your class is hardly customizable, for example if I want to customize the log for ""File Name: " + __FILE__ + "\n", I will have to modify your code, or to derive a class and rewrite the Log() method entirely. There is the same problem for whatever custom change needed, for example using a BIN file.
- You define a Print() macro which will override the MQL built-in one. It's a very poor idea to force the user of your library to Print() in your log.
Conclusion :
Your library is a correct basic Logging library. It can be convenient for some beginners or coders lacking the time to build their own, providing them some easy to use logging features.
By no way, using the qualifier "Best" is justified. The features are correct but basic, and the implementation is of amateurish level.
I read your "Best Logging Class" name, which attracted my attention. "Best" is placing the level quite high, so I was curious to check that. I will avoid to talk about the details, as it's a freely distributed code which requires to be indulgent.
Usage and features :
- Your hidden keywords idea is good. The implementation is weak though (See below). And it will silent too much messages, for example if I am using logging. AddSilentKeyword("start"), it will filter a log using "started" or "starting", which is really not what I would expect from a "keyword" filtering.
- The rest are very basic features. For example, as core of MQL are event driven, it's a must for a log system to avoid flooding the log with repeated same entry, which can happen easily with a Log() placed in a OnTick(), OnTimer() or OnChartEvent().
From a coding point of view :
- Your constructor and your Initialize() are duplicated code for the essential parts.
- Your IsMessageSilent() is using a loop check for each word of the m_silent_keywords[] and inside this loop you convert the 'keywords' to lower case. On each log ! It's really inefficient.
- Your class is hardly customizable, for example if I want to customize the log for ""File Name: " + __FILE__ + "\n", I will have to modify your code, or to derive a class and rewrite the Log() method entirely. There is the same problem for whatever custom change needed, for example using a BIN file.
- You define a Print() macro which will override the MQL built-in one. It's a very poor idea to force the user of your library to Print() in your log.
Conclusion :
Your library is a correct basic Logging library. It can be convenient for some beginners or coders lacking the time to build their own, providing them some easy to use logging features.
By no way, using the qualifier "Best" is justified. The features are correct but basic, and the implementation is of amateurish level.
I realize that "best" might be an overstatement compared to your expectations. My intention was to share code that could be easily modified and understood by anyone. I hope, however, that I have made a small contribution to the community, and the class is available for everyone to use. I will soon proceed to optimize the code as you suggested.
Thanks again for the feedback.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Best Logging Class for both MQL4 and MQL5:
The CDebugLogger class is a flexible and comprehensive logging utility designed for use in MQL4/5 environments. It allows developers to log messages at various levels of importance (INFO, WARNING, ERROR, DEBUG) with options to include timestamps, function signatures, file names, and line numbers in the log entries. The class supports logging to both the console and files, with the ability to save logs in a common folder and in CSV format. Additionally, it offers functionality to silence logs based on specific keywords, ensuring that sensitive information is not logged. This class is ideal for developers looking to implement robust logging mechanisms in their MQL4/5 applications, with customizable features that cater to a wide range of debugging and monitoring needs.
Author: VitalDefender Inc.