This example shows you the available functions in order to enable and control logging fo the C++ DLL. In default setup there is no logging active.

Enable Logging

If you want to make use of logging, please set up before using any of the other QR Invoice functions.

In order to enable logging you will need to provide a log file name.

#include <qrinvoice/logging.hpp>

// ...

// log file gets immediately created
qrinvoice::logging::set_log_file("logfile.txt");

// if you want the log file to only be created when needed, us the "lazy logger"
qrinvoice::logging::set_lazy_log_file("logfile.txt");

// set the desired minimum log level
// valid values: "trace", "debug", "info", "warning", "error", "critical", "off"
qrinvoice::logging::set_log_level("warning");

Control Flushing

Flushing is done whenever suitable. If you need to control or force flushing, the following is possible.

#include <qrinvoice/logging.hpp>

// ...

// flush occurs when error log events are encountered
qrinvoice::logging::set_flush_level("error");

// manual flush
qrinvoice::logging::flush();

Shutdown Logging

Logging can be terminated using the shutdown call. It makes sure threads are stopped and file is flushed and closed.

#include <qrinvoice/logging.hpp>

// ...

qrinvoice::logging::shutdown();