FullMt5McpByLeo/Src/Complex/Logs.mqh

63 lines
2.4 KiB
MQL5

2026-04-27 22:49:28 -05:00
//+------------------------------------------------------------------+
//| Logs.mqh |
//| Copyright 2026, Niquel Mendoza. |
//| https://www.mql5.com/es/users/nique_372 |
//+------------------------------------------------------------------+
#property copyright "Copyright 2026, Niquel Mendoza."
#property link "https://www.mql5.com/es/users/nique_372"
#property strict
2026-04-28 10:48:57 -05:00
#ifndef FULLMT5MCPBYLEO_SRC_COMPLEX_LOGS_MQH
#define FULLMT5MCPBYLEO_SRC_COMPLEX_LOGS_MQH
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
#include "Complex.mqh"
2026-04-27 22:49:28 -05:00
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
2026-06-03 20:39:25 -05:00
namespace TSN
{
2026-04-28 10:48:57 -05:00
class CMcpFunctionExpertLogs : public CMcpFunction
{
public:
CMcpFunctionExpertLogs(void) : CMcpFunction(0, false, "get_expert_logs") {}
~CMcpFunctionExpertLogs(void) {}
2026-07-13 21:11:54 -05:00
void Run(CJsonNode& param, CJsonBuilderStr* &out) override final;
2026-04-28 10:48:57 -05:00
};
//+------------------------------------------------------------------+
2026-07-13 21:11:54 -05:00
void CMcpFunctionExpertLogs::Run(CJsonNode &param, CJsonBuilderStr* &out)
2026-04-28 10:48:57 -05:00
{
2026-07-13 21:11:54 -05:00
//---
out = m_shared_builder;
2026-07-01 11:41:37 -05:00
uchar data[];
2026-06-03 20:39:25 -05:00
if(!ExtractLastLogLines(
2026-04-28 10:48:57 -05:00
StringToTime(param["start_date"].ToString(TimeToString(TimeCurrent()))),
2026-07-01 10:15:51 -05:00
int(param["byte_start"].ToInt(3)),
2026-07-01 09:24:34 -05:00
int(param["byte_counts"].ToInt(100)),
2026-07-01 11:41:37 -05:00
data
2026-04-28 10:48:57 -05:00
))
{
2026-07-13 21:11:54 -05:00
m_shared_builder.PutChar('"');
m_shared_builder.Obj();
m_shared_builder.KeyWV("ok").Val(false);
m_shared_builder.KeyWV("error").ValSWV("Error obtaining logs from the mt5 terminal");
m_shared_builder.EndObj();
m_shared_builder.PutChar('"');
2026-04-28 10:48:57 -05:00
}
else
{
2026-07-13 21:11:54 -05:00
m_shared_builder.PutChar('"');
m_shared_builder.Obj();
m_shared_builder.KeyWV("ok").Val(true);
m_shared_builder.KeyWV("result").ValU(data);
m_shared_builder.EndObj();
m_shared_builder.PutChar('"');
2026-04-28 10:48:57 -05:00
}
}
//+------------------------------------------------------------------+
2026-06-03 20:39:25 -05:00
} // namespace TSN
2026-07-01 09:24:34 -05:00
#endif // FULLMT5MCPBYLEO_SRC_COMPLEX_LOGS_MQH