Logger
The Logger plugin provides a flexible and customizable logging system that supports various logging behaviors. It allows controlling log output through flags, including options for printing timestamps, and printing log messages to the console. The location of the log file is flexible and can be set to be stored either alongside the application binary or within a system-specific configuration directory.
note
To initialize Logger plugin, the following global macros must be defined (shared with the Config plugin):
- TS_APP_NAME - Specifies the configuration file name (e.g., "MyApplication")
- TS_APP_PATH - Specifies the system configuration directory (e.g., ".tellusim")
- TS_APP_VERSION - Specifies the application version (e.g., "1.0")
#include <system/logger/include/TellusimLogger.h>
Example
// create local log (stored next to the application binary)
Logger::Flags flags = Logger::FlagNone;
flags |= Logger::FlagDate; // enable date in log
flags |= Logger::FlagTime; // enable time in log
flags |= Logger::FlagPrint; // print log messages
flags |= Logger::FlagLocal; // store log locally
Logger logger(flags);
// create context
Context context(PlatformAny);
if(!context.create()) return false;
// create device
Device device(context);
if(!device) return false;
// print device info
const auto &features = device.getFeatures();
TS_LOGF(Message, "GPU name: %s\n", device.getName().get());
TS_LOGF(Message, "GPU vendor: %s\n", device.getVendor().get());
TS_LOGF(Message, "GPU version: %s\n", device.getVersion().get());
TS_LOGF(Message, "GPU memory: %s\n", String::fromBytes(features.videoMemory).get());