Skip to content
All library documents

A Lightweight MQL5 Logger with Levels and Message Filters

Article MQL5 code base

Summary

This programming note presents a basic logging class for MQL5 trading projects, modeled loosely on Python logging. It supports severity levels from debug through critical, configurable message formatting, optional alert dialogs, and substring inclusion or exclusion filters. An assertion helper can log different messages and levels depending on whether a condition passes.

The note also identifies a performance issue: formatting a message with a string-formatting function happens before the logger can discard it for a disabled severity level. It recommends guarding expensive debug-message construction with a level check. The author says MQL5 lacks a way to pass a variable number of arguments for lazy formatting through the logger methods. No benchmarks or implementation details beyond usage examples are provided, and the material concerns trading software instrumentation rather than trading strategy.

Key ideas

  • The class offers severity-based logging, custom formats, alerts, and substring filters.
  • Inclusion and exclusion filters can be populated individually or from delimited text.
  • Message formatting may consume work even when the configured level suppresses the message.
  • A level guard avoids unnecessary formatting for verbose debug output.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.