Skip to content

Logging Functions

Pritesh Mhatre edited this page Nov 2, 2020 · 4 revisions

It is an open source logging library for AmiBroker. It has following features:

  • Print logs into files
  • Specify the log directory (via chart parameters)
  • Specify the file name (via chart parameters)
  • You also will get to save file with different formats (csv, log, txt)
  • Logs will be written in columns and you can specify column delimiters (helps to easily study the file in Excel)
  • Automatically creates a separate logging file for each symbol (in scanner mode)
  • Automatically creates a separate logging file for each day
  • Finally there is also a provision to enable/disable logs

AmiBroker Logging Library Parameters

The default logging path is: C:\Program Files\AmiBroker\Logs.

Note: If the framework experiences any errors due to file permission issues, then it will stop logging.

These functions are available in logs-util.afl. To use these functions, add following line at the top of your afl:

#include <logs-util.afl>

Functions

logTrace

Logs a TRACE category statement. Trace category is mostly used for detailed logging.

Example

logTrace("Order placed successfully.");
// Logs the given text to the file with TRACE category.

Parameters

Parameter Type Description
logText string The text that you want to log to the file

logDebug

Logs a DEBUG category statement. Debug is used for logging text that helps with debugging.

Example

logDebug("Order placed successfully.");
// Logs the given text to the file with DEBUG category.

Parameters

Parameter Type Description
logText string The text that you want to log to the file

logInfo

Logs a INFO category statement. Info category is mostly used for logging informative messages.

Example

logInfo("Order placed successfully.");
// Logs the given text to the file with INFO category.

Parameters

Parameter Type Description
logText string The text that you want to log to the file

logError

Logs an ERROR category statement. Error category is used for logging errors.

Example

logError("Order placement failed.");
// Logs the given text to the file with ERROR category.

Parameters

Parameter Type Description
logText string The text that you want to log to the file