Log Generation

Logging is essential for debugging and monitoring the SDK's behaviour and interactions with the vending machine controller (VMC).

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: Log most messages, excluding keep-alive and its ACK.
  • 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 in bin\debug\marshall.log
  • On the C SDK, the log location is determined by invoking the function Below
    void printk_register_puts(printk_puts_pfunc cb);
    
  • 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.