Log

Logging is essential for debugging and monitoring the SDK's behavior and interactions with the peripheral. It is Nayax's main tool for understanding what's happening on the peripheral's end, as well as in the connection between the device and peripheral.

Configuration

To have logs of the SDK, you need to configure the following flags in the main method:

  • dump_packets_level (vmc_configuration): Determines the level of detail required to log messages generated by the SDK. These are the options available:
    • debug_level_dump_none: Don't generate a log.
    • debug_level_dump_all: Log all messages.
    • debug_level_dump_moderate: Logs all messages, excluding keep-alives and their ACKs.
  • debug ( boolean): Enables or disables log generation.

You can add these flags to the main method, as in the example below.

public static void main(string[] args) {
    vmc_config.dump_packets_level = vmc_configuration.debug_level_dump_moderate;
    vmc_config.debug = true;
}
public class vend_machine
    vmc_config.debug = true;
    vmc_config.dump_packets_level = vmc_configuration.debug_level_dump_moderate;
vmc_init()
	config.dump_packets_level = debug_level_dump_none;

Log file location

The logs generated by the SDK are written to a specific file location.

  • On the C# SDK, the logs are automatically saved inside the same directory you run the SDK from, inside the bin\Debug folder. For example:

  • On the C SDK, the log location is determined by invoking the function below.

    printk_register_puts(terminal_tx_str);

The information the SDK writes is redirected to the board/console of your desire in which you'd like to save the file.
It is up for you, the developer, to decide where to write the output SDK logs:
Command line - like the x86/Linux example. UART port- like the STM example. Or any other choice as you desire.

static void terminal_tx_str(char *str)
{
    #if defined(__PLATFORM_X86) || defined(__PLATFORM_LINUX)
        printf("%s", str);
    #elif defined(__PLATFORM_STM32)
        drv_usart_tx_data(&terminal_usart, (uint8_t*)str, strlen(str));
    #endif
}

(The C SDK's demo app generates the log to the command line by default)

  • On the Java SDK, the default log file path is specified in the FileWriter initialization. See the following example.

    if (vmc_config.debug) {
      BufferedWriter out = null;
      try {
          FileWriter fstream = new FileWriter("c:\\out.txt", true); // true to append data
          out = new BufferedWriter(fstream);
          Log.initialize(out);
      } catch (Exception ex) {
          // Handle exception
      }
    }

In the code above, the log file is created at the root of the C: drive with the name out.txt. The true parameter in the FileWriter constructor indicates that data will be appended to the existing log file if it already exists.