cubos::core::tel::Logger class final

Singleton which holds the logging state.

Public types

struct Entry
Data created by a call to log.
struct Location
Identifies a location in the code.
struct Timestamp
A timestamp used to identify when a logging message was written.

Public static functions

static void level(Level level)
Sets the log level.
static auto level() -> Level
Gets the current log level.
static auto logToFile(const std::string& filePath) -> bool
Sets a file path where logs will be saved.
static auto logToFile() -> bool
Mounts a standard archive on the /logs/ directory, and calls logToFile to a timestamped log file on that directory.
static void write(Level level, Location location, std::string message)
Creates a new entry in the logs, as long as the log level is high enough.
template<typename... TArgs>
static void writeFormat(Level level, Location location, const char* format, TArgs... args)
Wrapper for write() with message formatting.
static auto read(std::size_t& cursor, Entry& entry) -> bool
Reads a log entry, if there's a new one.

Constructors, destructors, conversion operators

Logger() deleted
Deleted constructor.

Function documentation

static void cubos::core::tel::Logger::level(Level level)

Sets the log level.

Parameters
level New logging level.

If CUBOS_TEL_LEVEL is higher than the set level, entries below it are still not registered.

static Level cubos::core::tel::Logger::level()

Gets the current log level.

Returns Log level.

static bool cubos::core::tel::Logger::logToFile(const std::string& filePath)

Sets a file path where logs will be saved.

Parameters
filePath Path to file in the virtual file system.
Returns Whether the file could be opened for logging.

static bool cubos::core::tel::Logger::logToFile()

Mounts a standard archive on the /logs/ directory, and calls logToFile to a timestamped log file on that directory.

Returns Whether the file could be mounted and opened for logging.

static void cubos::core::tel::Logger::write(Level level, Location location, std::string message)

Creates a new entry in the logs, as long as the log level is high enough.

Parameters
level Log level.
location Code location.
message Log message.

template<typename... TArgs>
static void cubos::core::tel::Logger::writeFormat(Level level, Location location, const char* format, TArgs... args)

Wrapper for write() with message formatting.

Template parameters
TArgs Message format argument types.
Parameters
level Log level.
location Code location.
format Message format string.
args Message format arguments.

static bool cubos::core::tel::Logger::read(std::size_t& cursor, Entry& entry)

Reads a log entry, if there's a new one.

Parameters
cursor out Index of the entry to be read. Automatically increased.
entry out Entry to read into.
Returns Whether an entry was red.