Expert Advisors • Indicators • Scripts • Libraries

MQL.RobotFX.org is the biggest collection of MetaTrader expert advisors (MT5 & MT4), indicators, scripts and libraries that can be used to improve trading results, minimize risks or simply automate trading tasks

MetaTrader 5 Libraries | CTsLogger is a simple and flexible logging system

MetaTrader Experts, Indicators, Scripts and Libraries

CTsLogger is a simple and flexible logging system specially designed for creating and debugging trading systems in MQL5. The main advantage of CTsLogger is the ability to temporarily enable the debugging mode for specific modules or code sections while maintaining a lower global logging level. Thus, you can get detailed logging of certain code sections without "drowning" in the flow of messages, and then disable it with one command.

.

CTsLogger supports 4 levels of logging, in ascending order of detail:

1. LOG_LEVEL_ERROR - errors 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


CTsLogger supports hierarchical module identifiers separated by a dot, which allows you to organise modules into a logical structure. The hierarchy can have any nesting depth.

Full API

Creation and initialisation

- `CTsLogger()` - constructor

- `~CTsLogger()` - destructor

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

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

Methods of logging

-`Error(string moduleId, string message)` - logging of errors

-`Warning(string moduleId, string message)` - logging warnings

- `Info(string moduleId, string message)` - logging of information messages

-`Debug(string moduleId, string message)` - logging debug messages

Basic debug mode control

- `EnableDebugMode(string moduleId)` - enabling debug mode for a module

- `DisableDebugMode(string moduleId)` - disable debug mode for a module and all its child modules

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

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

- `DisableDebugModeAll()` - disable global debug mode with saving of modules settings

Advanced debug mode control

- `PauseDebugMode()` - temporary suspension of debug mode for all modules

- `ResumeDebugMode()` - resume debug mode for previously configured modules

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

- `ResetDebugModules()` - complete reset of all debug modules

- `HasChildDebugModules(string parentModule)` - check if child modules are in debug mode


58105