FullMt5McpByLeo/Src/Complex/Logs.mqh

58 lines
2.2 KiB
MQL5
Raw Permalink Normal View History

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
{
2026-07-01 09:24:34 -05:00
private:
CJsonBuilder m_json_builder;
2026-04-28 10:48:57 -05:00
public:
CMcpFunctionExpertLogs(void) : CMcpFunction(0, false, "get_expert_logs") {}
~CMcpFunctionExpertLogs(void) {}
void Run(CJsonNode& param, string& res) override final;
};
//+------------------------------------------------------------------+
void CMcpFunctionExpertLogs::Run(CJsonNode &param, string &res)
{
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-06-03 20:39:25 -05:00
res = "{\"ok\":false,\"error\":\"Error obtaining logs from the mt5 terminal\"}";
2026-04-28 10:48:57 -05:00
}
else
{
2026-07-01 11:41:37 -05:00
m_json_builder.Clear();
2026-07-01 09:24:34 -05:00
m_json_builder.Obj();
m_json_builder.Key("ok").Val(true);
2026-07-01 11:41:37 -05:00
m_json_builder.Key("result").ValU(data);
2026-07-01 09:24:34 -05:00
m_json_builder.EndObj();
2026-07-01 11:41:37 -05:00
res = m_json_builder.Build();
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