//+------------------------------------------------------------------+ //| Logs.mqh | //| Copyright 2026, Niquel Mendoza. | //| https://www.mql5.com/ | //+------------------------------------------------------------------+ #property copyright "Copyright 2026, Niquel Mendoza." #property link "https://www.mql5.com/" #property strict #ifndef LLMAGENTSBASICTOOLS_SRC_UTILS_LOGS_MQH #define LLMAGENTSBASICTOOLS_SRC_UTILS_LOGS_MQH //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ #include "..\\Def.mqh" //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ namespace TSN { //+------------------------------------------------------------------+ //| name: get_expert_logs | //| desc: Returns the last lines of the expert/terminal log | //| params: | //| start_date string Date from which to read the log. Default | //| is the current time | //| byte_start integer Byte offset to start reading. Default 3 | //| byte_counts integer Amount of bytes to read. Default 100 | //+------------------------------------------------------------------+ class CLlmBToolGetExpertLogs : public CLLmTool { public: CLlmBToolGetExpertLogs(void) : CLLmTool("get_expert_logs") {} ~CLlmBToolGetExpertLogs(void) {} void Run(CJsonNode& param, CJsonBuilderStr* &out) override final { out = m_shared_builder; uchar data[]; if(!ExtractLastLogLines( StringToTime(param["start_date"].ToString(TimeToString(TimeCurrent()))), int(param["byte_start"].ToInt(3)), int(param["byte_counts"].ToInt(100)), data )) { m_shared_builder.PutChar('"'); m_shared_builder.Obj(); m_shared_builder.KeyWV("ok").Val(false); m_shared_builder.KeyWV("error").ValS("Error obtaining logs from the mt5 terminal"); m_shared_builder.EndObj(); m_shared_builder.PutChar('"'); return; } //--- 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('"'); } }; } //+------------------------------------------------------------------+ #endif // LLMAGENTSBASICTOOLS_SRC_UTILS_LOGS_MQH