Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

CTsLogger is a simple and flexible logging system - MetaTrader 5 library - MT4/MT5 resources

author EAcpu | 6 reads | 0 comments |

CT Logger is a simple and flexible logging system designed for creating and debugging trading systems in MQL5. Key Benefits CT Logger has the ability to temporarily enable debugging mode for a specific module or section of code while maintaining a low global logging level. So you can get verbose logging of certain parts of your code without "flooding" it in the message flow, and then disable it with a single command.

.

The CT recorder supports 4 levels of logging, in ascending order of details:

1. LOG_LEVEL_ERROR - Error only

2. LOG_LEVEL_WARNING - warnings and errors

3. LOG_LEVEL_INFO - Information messages, warnings and errors

4. LOG_LEVEL_DEBUG - Debug messages, informational messages, warnings and errors


CT recorders support dot-delimited hierarchical module identifiers, which allows you to organize modules into a logical structure. Hierarchies can have any nesting depth.

Create and initialize

- `CTsLogger()` - constructor

- `~CTsLogger()` - destructor

- `Initialize(string logFileName, bool logToTerminal = true)` - Initialization of the logger

- `SetGlobalLogLevel(ENUM_LOG_LEVEL level)` - Set global logging level

method Record

- `Error(String moduleId, String Message)` - logged mistake

- `warning(String moduleId, String message)` - logging warn

- `Info(string moduleId, string message)` - record information message

- `debug(String moduleId, String message)` - logging debug information

Basic debug mode controls

- `EnableDebugMode(string moduleId)` - Enable the debug mode of the module

- `DisableDebugMode(string moduleId)` - Disable debug mode for a module and all its submodules

- `IsInDebugMode(string moduleId)` - Check if debug mode is enabled

- `EnableDebugModeAll()` - Enable debug mode for all modules

- `DisableDebugModeAll()` - disable global debug mode and save module settings

Advanced debug mode control

- `PauseDebugMode()` - Temporarily pause debug mode for all modules

- `ResumeDebugMode()` - Resumes the debug mode of a previously configured module

- `IsDebugModePaused()` - Check if debug mode is paused

- `ResetDebugModules()` - Completely resets all debug modules

- `HasChildDebugModules(stringparentModule)` - Check if the submodule is in debug mode


Attachment download

📎ctslogger.mqh (19.86 KB)

📎tsloggertest.mq5 (3.84 KB)

📎ctslogger-readme.txt (10.14 KB)

📎ctslogger-readme-eng.txt (9.57 KB)

Source: MQL5 #58105

Verification code Refresh