|
C++ YASMIN (Yet Another State MachINe)
|
Namespaces | |
| namespace | blackboard |
Classes | |
| class | CbState |
| Represents a state that executes a callback function. More... | |
| class | Concurrence |
| Runs a series of states in parallel. More... | |
| class | State |
| Represents a state in a state machine. More... | |
| class | StateMachine |
| A class that implements a state machine with a set of states, transitions, and callback mechanisms for state changes. More... | |
Typedefs | |
| typedef void(* | LogFunction) (LogLevel level, const char *file, const char *function, int line, const char *text) |
| Type definition for a logging function. | |
Enumerations | |
| enum | LogLevel { ERROR = 0 , WARN , INFO , DEBUG } |
| Enum representing different log levels for controlling log verbosity. More... | |
Functions | |
| void | set_log_level (LogLevel level) |
| Sets the log level for the logs. | |
| const char * | log_level_to_name (LogLevel level) |
| Parse LogLevel to string. | |
| template<yasmin::LogLevel LEVEL> | |
| void | log_helper (const char *file, const char *function, int line, const char *text,...) |
| Variadic template function to log messages at different levels. | |
| const char * | extract_filename (const char *path) |
| Extracts the filename from a given file path. | |
| void | set_loggers (LogFunction log_message) |
| Sets custom logging functions for different log levels. | |
| void | set_default_loggers () |
| Sets the default logging function for all log levels. | |
| void | default_log_message (LogLevel level, const char *file, const char *function, int line, const char *text) |
| Default logging function. | |
Variables | |
| LogLevel | log_level = INFO |
| The current log level for the application. | |
| LogFunction | log_message = default_log_message |
| Pointer to the logging function. | |
| typedef void(* yasmin::LogFunction) (LogLevel level, const char *file, const char *function, int line, const char *text) |
Type definition for a logging function.
This type represents a function pointer that takes a file name, function name, line number, log message, and a variable number of additional arguments for formatting the log message.
| level | The log level of the message |
| file | The name of the source file where the log function is called. |
| function | The name of the function where the log function is called. |
| line | The line number in the source file where the log function is called. |
| text | The format string for the log message, similar to printf. |
| ... | Additional arguments for the format string. |
| enum yasmin::LogLevel |
Enum representing different log levels for controlling log verbosity.
This enum defines the severity levels of logs that can be used to control which log messages should be displayed. The levels are ordered from most severe to least severe. Only logs at or above the current log level will be shown.
| void yasmin::default_log_message | ( | LogLevel | level, |
| const char * | file, | ||
| const char * | function, | ||
| int | line, | ||
| const char * | text ) |
Default logging function.
| level | The log level as a string (e.g., "ERROR", "WARN", "INFO", "DEBUG"). |
| file | The source file where the log function is called. |
| function | The function where the log function is called. |
| line | The line number in the source file. |
| text | The format string for the log message. |
| args | Additional arguments for the format string. |
|
inline |
Extracts the filename from a given file path.
This function takes a full path to a file and returns just the file name.
| path | The full path to the file. |
| void yasmin::log_helper | ( | const char * | file, |
| const char * | function, | ||
| int | line, | ||
| const char * | text, | ||
| ... ) |
Variadic template function to log messages at different levels.
This function wraps log_message and allows logging messages with different log levels while reducing redundant code. It provides a consistent logging format across all levels.
| LEVEL | The log level LogLevel (e.g., 0 -> "ERROR", 1 -> "WARN", 2 -> "INFO", 3 -> "DEBUG"). |
| log_message | Function to create the logs |
| file | The source file where the log function is called. |
| function | The function where the log function is called. |
| line | The line number in the source file. |
| text | The format string for the log message. |
| ... | Additional arguments for the format string. |
| const char * yasmin::log_level_to_name | ( | LogLevel | level | ) |
Parse LogLevel to string.
This function returns the name of a given log level.
| level | Log level. |
| void yasmin::set_default_loggers | ( | ) |
Sets the default logging function for all log levels.
This function initializes the logging function to the default implementations.
| void yasmin::set_log_level | ( | LogLevel | level | ) |
Sets the log level for the logs.
This function allows the user to specify the log level error, warning, info, or debug.
| log_level | Log level. |
| void yasmin::set_loggers | ( | LogFunction | log_message | ) |
Sets custom logging functions for different log levels.
This function allows the user to specify custom logging functions for error, warning, info, and debug logs. If a null function is provided for any log level, the default logging function will be used instead.
| error | Pointer to the custom error logging function. |
| warn | Pointer to the custom warning logging function. |
| info | Pointer to the custom info logging function. |
| debug | Pointer to the custom debug logging function. |
The current log level for the application.
This global variable holds the current log level, which determines the verbosity of the logs. Logs at or above this level will be displayed. The default level is set to INFO.
| LogFunction yasmin::log_message = default_log_message |
Pointer to the logging function.