Logging facility, supports verbosity levels.
More...
#include <Library/UefiLib.h>
#include <Library/MemoryAllocationLib.h>
#include <UEFIStarter/core/logger.h>
Logging facility, supports verbosity levels.
- Author
- Richard Nusser
- Copyright
- 2017-2018 Richard Nusser
- License
- GPLv3 (see http://www.gnu.org/licenses/)
- See also
- https://github.com/rinusser/UEFIStarter
◆ LOGGER_FORWARD_FUNC
#define LOGGER_FORWARD_FUNC |
( |
|
NAME, |
|
|
|
LEVEL |
|
) |
| |
Value:static void EFIAPI NAME(CHAR16 *fmt, ...) \
{ \
VA_START(args,fmt); \
_logger_function_va(LEVEL,fmt,args); \
VA_END(args); \
}
cmdline_argument_t args[]
list of command-line arguments
Definition: rotation.c:30
helper macro for quickly defining a callable logging function
- Parameters
-
NAME | the logging function's name |
LEVEL | the log level to log at |
◆ get_log_level()
Fetches the current log level.
- Returns
- the current log level
◆ set_log_level()
Sets a new log level.
You can disable logging by calling this with log level "OFF".
- Parameters
-
level | the new log level to use |
- Returns
- the previous log level
◆ log_print()
void log_print |
( |
LOGLEVEL |
level, |
|
|
CHAR16 * |
msg |
|
) |
| |
Default log writer: prints to text console.
- Parameters
-
level | the log level to log at |
msg | the log message, as UTF-16 |
◆ _logger_function_va()
static void _logger_function_va |
( |
LOGLEVEL |
level, |
|
|
UINT16 * |
message, |
|
|
VA_LIST |
args |
|
) |
| |
|
static |
internal: formats log message and calls log writer with final string to log.
This function uses the same format strings as the Print() functions.
- Parameters
-
level | the log level to log at |
message | the message's format string |
args | the vararg list of parameters matching matching the format string's placeholder |
◆ _trace()
static void EFIAPI _trace |
( |
CHAR16 * |
fmt, |
|
|
|
... |
|
) |
| |
|
static |
internal: forwards TRACE messages to internal handler
- Parameters
-
fmt | the log entry's format string |
... | any additional parameters to be formatted |
◆ _debug()
static void EFIAPI _debug |
( |
CHAR16 * |
fmt, |
|
|
|
... |
|
) |
| |
|
static |
internal: forwards DEBUG messages to internal handler
- Parameters
-
fmt | the log entry's format string |
... | any additional parameters to be formatted |
◆ _info()
static void EFIAPI _info |
( |
CHAR16 * |
fmt, |
|
|
|
... |
|
) |
| |
|
static |
internal: forwards INFO messages to internal handler
- Parameters
-
fmt | the log entry's format string |
... | any additional parameters to be formatted |
◆ _warn()
static void EFIAPI _warn |
( |
CHAR16 * |
fmt, |
|
|
|
... |
|
) |
| |
|
static |
internal: forwards WARN messages to internal handler
- Parameters
-
fmt | the log entry's format string |
... | any additional parameters to be formatted |
◆ _error()
static void EFIAPI _error |
( |
CHAR16 * |
fmt, |
|
|
|
... |
|
) |
| |
|
static |
internal: forwards ERROR messages to internal handler
- Parameters
-
fmt | the log entry's format string |
... | any additional parameters to be formatted |
◆ reset_logger_entry_counts()
void reset_logger_entry_counts |
( |
| ) |
|
Resets all log levels' message counts.
Used e.g. by the test framework to detect which tests generated errors.
◆ get_logger_entry_count()
UINTN get_logger_entry_count |
( |
LOGLEVEL |
level | ) |
|
Gets a log level's message count.
- Parameters
-
level | the log level to get the count for |
- Returns
- the number of logged messages at the given level since the last reset
◆ kill()
Immediately halts the UEFI environment.
Use this to e.g. debug issues in graphical animations where it's vital to stop everything before the target gets painted over.
Technically the emitted interrupt 3 is usually used for debuggers but the UEFI specification requires INT 3 to be unassigned by default, thus halting everything. If you use this function with a debugger attached this will probably trigger the debugger instead.
◆ set_logger_function()
Sets a new log writer.
Use this to replace the built-in text mode writer, e.g. to output log messages in a graphical environment
- Parameters
-
func | the new log writer function |
- Returns
- the previous log writer function
◆ LOG
Initial value:={
}
static void EFIAPI _error(CHAR16 *fmt,...)
internal: forwards ERROR messages to internal handler
Definition: logger.c:132
static void EFIAPI _warn(CHAR16 *fmt,...)
internal: forwards WARN messages to internal handler
Definition: logger.c:125
static void EFIAPI _trace(CHAR16 *fmt,...)
internal: forwards TRACE messages to internal handler
Definition: logger.c:104
static void EFIAPI _info(CHAR16 *fmt,...)
internal: forwards INFO messages to internal handler
Definition: logger.c:118
static void EFIAPI _debug(CHAR16 *fmt,...)
internal: forwards DEBUG messages to internal handler
Definition: logger.c:111
The global logging facility.
This contains function pointers for each log level, so users can call e.g. LOG.debug() to log a debug message.