HeexLog class

In both c++ and python we provide a HeexLog class, instantiated from the spdlog library. We recommend logging through this class since we have included builtin behaviors (like logging into specific files) that allow a smoother experience. To use it, you must first include it:
#include "HeexUtilsLog.h"
Once included, it is instantiated, and everywhere you include this, the same instance shall be used for a single executable. It creates a logs folder next to your executable, and creates a [executable_name].log file inside it. To log, use the following format:
HeexLog::info("information level")
HeexLog::warn("warning level")
HeexLog::error("error level")
HeexLog::critical("critical level")
The logger has a builtin rotating file sink that automatically starts logging into a new file when a certain size has been reached. The default values are 20 Mb and 5 files. This means that when you instanciate your logger and it starts logging into [executable_name].log, once this file reaches 20Mb, it creates a new file [executable_name]_0.log and continues logging in there. Once that file reaches 20Mb, it creates a new one until 5 files are created like this. Once the 5th file reaches 20Mb, the logging clears the first file and logs into that one. These default values can be changed by calling the following command:
  HeexLog::setRotatingFileSinkConf(<sizeInBytes>, <maxNumberOfFiles>);
HeexLog::setRotatingFileSinkConf(<sizeInBytes>, <maxNumberOfFiles>);
If you leave any of the inputs at 0, it’ll take the default value. In addition to the rotating file sink, we have included some additional methods you may chose to call:
  • Enable or Disable the logging into a log file (only console logging):
HeexLog::disableLogToFile();
HeexLog::info("This message shall only be logged into your console")
HeexLog::enableLogToFile();
HeexLog::info("This message shall be logged into your console and into the log file")
  • Set logging level:
    Possible values are “default” (e.g. ‘info’), “trace”, “debug”, “info”, “warn”, “warning”, “error”, “critical”
    All other strings given shall set to info.
HeexLog::setLogLevel("warn");
HeexLog::info("This message shall not be logged.")
  • get and clear the active log file:
filepath = HeexLog::getActiveLogFilepath(); // returns the path to the current active log file
HeexLog::clearActiveLogFile(); // The log file is now empty.