2026-07-13 14:48:50 -05:00
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
//| 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) {}
|
|
|
|
|
|
2026-07-15 12:34:01 -05:00
|
|
|
void Run(CJsonNode& param, CJsonBuilderStr* &out) override final
|
2026-07-13 14:48:50 -05:00
|
|
|
{
|
2026-07-15 12:34:01 -05:00
|
|
|
out = m_shared_builder;
|
2026-07-13 14:48:50 -05:00
|
|
|
uchar data[];
|
|
|
|
|
if(!ExtractLastLogLines(
|
|
|
|
|
StringToTime(param["start_date"].ToString(TimeToString(TimeCurrent()))),
|
|
|
|
|
int(param["byte_start"].ToInt(3)),
|
|
|
|
|
int(param["byte_counts"].ToInt(100)),
|
|
|
|
|
data
|
|
|
|
|
))
|
|
|
|
|
{
|
2026-07-15 12:34:01 -05:00
|
|
|
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('"');
|
2026-07-13 14:48:50 -05:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---
|
2026-07-15 12:34:01 -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-07-13 14:48:50 -05:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
#endif // LLMAGENTSBASICTOOLS_SRC_UTILS_LOGS_MQH
|