Files
MQL5Data/Documents/BKP/Docs/XCAlert.md
T
2026-07-10 04:24:32 +03:30

3.6 KiB

XCAlert

it is a module which used for Providing Logs in SaherElm's XTrade Framework.

Dependencies

this Module used XCDataCollector for Saving Logs in Files.

Instancing

using this syntax for instancing :

XCAlert(
    string prefix = "X-Alert",   // Alerts Prefixe
    bool enableAlerts = true,    // Enable Alerts
    bool logAlerts = true,       // Log Alerts
    bool terminalAlerts = false, // Terminal Alerts
    bool mailAlerts = false,     // Mail Alerts
    bool pushAlerts = false,     // Push Alerts
    bool saveAlerts = false      // Save Alerts
) {}

all of Constructor Input args is Optional, means have default values. you can set them after instancing using Properties Setter/Getter (s).

Instructions

  • Prefix: string, Specified Logger Prefix. this for Separate Different Logger Instances.
  • EnableAlerts: boolean, Specified Logging is Enabled or not.
  • SaveAlerts: boolean, Specified Saving Log(s) or not.
  • LogAlerts: boolean, Specified Can Print Logs on Console or not.
  • TerminalAlerts: boolean, Specified Send Logs in Terminal or not.
  • MailAlerts: boolean, Specified Send Logs as Mail or not.
  • PushAlerts: boolean, Specified Send Logs as Push or not.

Actions

LogAlert(string message)

do specified type of Logs. do log by Print in Console.

TerminalAlert(string message)

do specified type of Logs. do log by sending Terminal Alert.

MailAlert(string message)

do specified type of Logs. do log by sending Mail Alert.

PushAlert(string message)

do specified type of Logs. do log by sending Push Notification Alert.

SendAlert(string message)

do sending log by configuration. retrieve log and based on configuration send each specified enabled logs separately.

Log(string message)

Checking Log Flag and Print Message.

Log(string tag, string message)

Checking Log Flag and Print Specified Tag & Message.

LogEmpty()

Checking Log Flag and Print Empty Message.

LogArray(T &array[], string label = NULL)

Checking Log Flag and Print Array.

LogError(int error = -1)

Checking Log Flag and then Generate Error Message based on provided error number, then Print Tag Specified Message.

string GetErrorDescription(int err_code)

Generate Specified Error Messaged based on Provided error code.

string GetTradeServerReturnCodeDescription(int return_code)

Generate Specified Error Message based on Provided server error code.

bool CanLog()

protected return a Flag for Specified Flag which allowed Print Logs or not.

bool CanLogAlert()

protected return a Flag for Specified Flag which allowed Print Logs and also Enabled or not.

bool CanTerminalAlert()

protected return a Flag for Specified Flag which allowed Sending Logs to Terminal and also Enabled or not.

bool CanMailAlert()

protected return a Flag for Specified Flag which allowed Sending Logs as Mail and also Enabled or not.

bool CanPushAlert()

protected return a Flag for Speified Flag which allowed Sending Logs as Push and also Enabled or not.

Save(string message)

protected Saving Specified Message into Logger File. if alert Saving is Enabled.

Descriptions

  • Preparing a File Name by Combining setted Prefix + ".XLogs".
  • Generating File Path based on XCDataCollector instance Path.
  • Validate Generated filePath.
  • Preparing Log Message for Saving in Log File by attaching Current Time.
  • Append prepared Message to Log File using XCDataCollector instance.

string PrepareMessage(string message)

private Replace Escaped strings and Attach Prefix to Message.

Maintainer

Hadi Khazaee asl

https://www.saherelm.ir

hadi_khazaee_asl@yahoo.com