C++ YASMIN (Yet Another State MachINe)
Loading...
Searching...
No Matches
logs.hpp File Reference
#include <cstdarg>
#include <cstring>
#include <string>
Include dependency graph for logs.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  yasmin
 

Macros

#define YASMIN_LOG_ERROR(text, ...)
 
#define YASMIN_LOG_WARN(text, ...)
 
#define YASMIN_LOG_INFO(text, ...)
 
#define YASMIN_LOG_DEBUG(text, ...)
 

Typedefs

typedef void(* yasmin::LogFunction) (LogLevel level, const char *file, const char *function, int line, const char *text)
 Type definition for a logging function.
 

Enumerations

enum  yasmin::LogLevel { yasmin::ERROR = 0 , yasmin::WARN , yasmin::INFO , yasmin::DEBUG }
 Enum representing different log levels for controlling log verbosity. More...
 

Functions

void yasmin::set_log_level (LogLevel level)
 Sets the log level for the logs.
 
const char * yasmin::log_level_to_name (LogLevel level)
 Parse LogLevel to string.
 
template<yasmin::LogLevel LEVEL>
void yasmin::log_helper (const char *file, const char *function, int line, const char *text,...)
 Variadic template function to log messages at different levels.
 
const char * yasmin::extract_filename (const char *path)
 Extracts the filename from a given file path.
 
void yasmin::set_loggers (LogFunction log_message)
 Sets custom logging functions for different log levels.
 
void yasmin::set_default_loggers ()
 Sets the default logging function for all log levels.
 

Variables

LogLevel yasmin::log_level = INFO
 The current log level for the application.
 
LogFunction yasmin::log_message = default_log_message
 Pointer to the logging function.
 

Macro Definition Documentation

◆ YASMIN_LOG_DEBUG

#define YASMIN_LOG_DEBUG ( text,
... )
Value:
yasmin::log_helper<yasmin::DEBUG>(extract_filename(__FILE__), __FUNCTION__, \
__LINE__, text, ##__VA_ARGS__)
LogLevel log_level
The current log level for the application.
Definition logs.cpp:41
@ DEBUG
Definition logs.hpp:44

◆ YASMIN_LOG_ERROR

#define YASMIN_LOG_ERROR ( text,
... )
Value:
yasmin::log_helper<yasmin::ERROR>(extract_filename(__FILE__), __FUNCTION__, \
__LINE__, text, ##__VA_ARGS__)
@ ERROR
Log level for error messages. Only critical errors should be logged.
Definition logs.hpp:35

◆ YASMIN_LOG_INFO

#define YASMIN_LOG_INFO ( text,
... )
Value:
yasmin::log_helper<yasmin::INFO>(extract_filename(__FILE__), __FUNCTION__, \
__LINE__, text, ##__VA_ARGS__)
@ INFO
Definition logs.hpp:41

◆ YASMIN_LOG_WARN

#define YASMIN_LOG_WARN ( text,
... )
Value:
yasmin::log_helper<yasmin::WARN>(extract_filename(__FILE__), __FUNCTION__, \
__LINE__, text, ##__VA_ARGS__)
@ WARN
Definition logs.hpp:38