거래 로봇을 무료로 다운로드 하는 법을 시청해보세요
당사를 Facebook에서 찾아주십시오!
당사 팬 페이지에 가입하십시오
스크립트가 흥미로우신가요?
그렇다면 링크 to it -
하셔서 다른 이들이 평가할 수 있도록 해보세요
스크립트가 마음에 드시나요? MetaTrader 5 터미널에서 시도해보십시오
라이브러리

Logify - Library for log management - MetaTrader 5용 라이브러리

조회수:
1214
평가:
(1)
게시됨:
업데이트됨:
\MQL5\Experts\Logify\ \MQL5\Include\Logify\
Logify.mqh (25.24 KB) 조회
\MQL5\Include\Logify\Utils\ \MQL5\Include\Logify\Suppression\ \MQL5\Include\Logify\Handlers\ \MQL5\Include\Logify\Formatter\ \MQL5\Include\Logify\Error\Languages\ \MQL5\Include\Logify\Error\
Error.mqh (0.55 KB) 조회
LogifyError.mqh (14.29 KB) 조회
MQL5 프리랜스 이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동

Logify is a logging library for MQL designed to simplify debugging, tracking, and monitoring of EAs and indicators. It provides structured, customizable, and organized logs directly on the chart or in the terminal, with support for log levels, flexible formats, and multiple handlers. A lightweight, elegant solution that is easy to integrate into your MQL projects.


📦 Features

  • Multiple log levels: DEBUG, INFO, ALERT, ERROR, FATAL
  • Display logs directly on graph, terminal, files or even database
  • Customizable log format and layout
  • Modular architecture with multiple handlers
  • Lightweight and easy to integrate and use


🚀 Installation

  1. Copy the folder /Logify to:
    MQL5/Include/
  2. Include Logify in your EA, indicator or script:
    #include <Logify/Logify.mqh>
  3. It is possible to install using Git, just access the repository and follow the steps.



🔧 Quick Start Example

Simple example with default settings:

//+------------------------------------------------------------------+
//| Import                                                           |
//+------------------------------------------------------------------+
#include <Logify/Logify.mqh>
CLogify Logify;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   //--- Example logs
   Logify.Debug("Initialization started");
   Logify.Info("Account balance is OK");
   Logify.Alert("Take profit reached");
   Logify.Error("Failed to send order", "Order", "Reason: No money");
   Logify.Fatal("Critical error: Invalid input parameters");

   //---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+

Advanced example, with custom handler settings. In this example, we save the log record to files and in the graph comment. Customizing the settings for each of them.

//+------------------------------------------------------------------+
//| Import                                                           |
//+------------------------------------------------------------------+
#include <Logify/Logify.mqh>
CLogify Logify;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   //--- Configure comment handler
   MqlLogifyHandleCommentConfig config_comment;
   config_comment.size = 10;
   config_comment.frame_style = LOG_FRAME_STYLE_SINGLE;
   config_comment.direction = LOG_DIRECTION_UP;
   config_comment.title = "My Expert";

   //--- Create and configure comment handler
   CLogifyHandlerComment *handler_comment = new CLogifyHandlerComment();
   handler_comment.SetConfig(config_comment);
   handler_comment.SetLevel(LOG_LEVEL_DEBUG);
   handler_comment.SetFormatter(new CLogifyFormatter("{date_time} [{levelname}]: {msg}","hh:mm:ss"));
   
   //--- Configure file handler
   MqlLogifyHandleFileConfig file_config;
   file_config.CreateDateRotationConfig("my_expert","logs",LOG_FILE_EXTENSION_LOG,10,100,CP_UTF8);
   
   //--- Create and configure file handler
   CLogifyHandlerFile *handler_file = new CLogifyHandlerFile();
   handler_file.SetConfig(file_config);
   handler_file.SetLevel(LOG_LEVEL_DEBUG);
   handler_file.SetFormatter(new CLogifyFormatter("{date_time} [{levelname}]: {msg} ({filename} | {origin} | {function})","hh:mm:ss"));
   
   //--- Attach handler
   Logify.AddHandler(handler_comment);
   Logify.AddHandler(handler_file);

   //--- Example logs
   Logify.Debug("Initialization started");
   Logify.Info("Account balance is OK");
   Logify.Alert("Take profit reached");
   Logify.Error("Failed to send order", "Order", "Reason: No money");
   Logify.Fatal("Critical error: Invalid input parameters");
   
   //---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+

To understand each of the settings, I recommend reading the articles below, where I explain each step of the library development:


✔️ Log Levels

Level
Description
DEBUG
Verbose information for debug
INFO
General information
ALERT
Warnings or important events
ERROR
Errors that require attention
FATAL
Critical errors, stop execution


🖥️ Handlers Included

Each handler defines where the logs will be displayed or stored.

Handler
Description
Comment
Display logs directly on the graph (Comment)
Console
Show logs in MetaTrader terminal
File
Save logs to .txt or .log files
Database Stores logs in local SQLite database

You can use one or combine several handlers at the same time, like graphic + file + console, for example.


🛠️ Log Format

Example of formatting pattern:

"{date_time} [{levelname}]: {msg}"

Available tokens:

  • {levelname}: Level name (DEBUG, INFO, ERROR, etc.)
  • {msg}: Main message
  • {args}: Additional arguments or details
  • {timestamp}: Timestamp in seconds (Unix Time)
  • {date_time}: Formatted date and time (hh:mm:ss, etc.)
  • {level}: Numeric code for the level (0 = DEBUG, 1 = INFO...)
  • {origin}: Origin or context defined in the log call
  • {filename}: Source file name (if available)
  • {function}: Name of the function from which it was called
  • {line}: Line number in the code where the log occurred


⚖️ License

MIT License — Free to use for personal and commercial projects.


👨‍💻 Author

Developed by joaopedrodev, with a focus on making MQL development more professional, organized and efficient.

Disconnect Alerts for MT5 Disconnect Alerts for MT5

Trade server disconnect alerts utility for MT5.

Copy Trader Copy Trader

Good afternoon guys, I'm a new student on metatrader5, I'm creating a robot to copy trades from a demo account and save them in a database I'd like some help identifying possible problems, best solutions for the code, etc.

Adaptive CCI Adaptive CCI

Adaptive CCI - Commodity Channel Index with dynamically adjusting upper and lower limits based on market volatility. Eliminates fixed thresholds (like 100/-100) by using EMA-smoothed peaks and troughs, providing more reliable overbought/oversold signals tailored to each asset's current volatility. Perfect for identifying high-probability reversal points with adaptive confirmation levels.

ZigZag WaveSize ZigZag WaveSize

Modified standard ZigZag indicator with the addition of information about wavelength in pips, levels and different alerts logic