|
typedef void(* | hc_log_fun_t )(int, const char *, const char *) |
|
libhamcast provides its own logging mechanism. It's inteded for debugging of libhamcast, the middleware and technology modules only and must be enabled at compile by defining HC_ENABLE_LOGGING
.
Usage example (C++):
#include "hamcast/hamcast_logging.h"
void fun1(int arg1, int arg2)
{
}
int main(int, char**)
{
fun1(1, 2);
return 0;
}
#define HC_LOG_DEBUG |
( |
|
message | ) |
|
Constant for logging of debug informations.
#define HC_LOG_ERROR |
( |
|
message | ) |
|
Constant for logging of errors.
#define HC_LOG_FATAL |
( |
|
message | ) |
|
Constant for logging of fatal errors.
#define HC_LOG_INFO |
( |
|
message | ) |
|
Constant for logging of runtime informations.
#define HC_LOG_SCOPE |
( |
|
scope_name, |
|
|
|
message |
|
) |
| |
Log tracing informations for the current scope.
- Parameters
-
scope_name | The user defined name of the scope. This name is written to the log instead of the enclosing function name. |
message | The user defined log message. |
- See Also
- HC_LOG_TRACE(message)
#define HC_LOG_TRACE |
( |
|
message | ) |
|
Log tracing informations for the current function.
If you're compiling C++ then this logs an ENTER event with message
and an EXIT event if the function is leaved.
- Parameters
-
message | The user defined log message. |
- Note
- If you're compiling C++,
message
will be streamed. This allows you to use the stream operator: HC_LOG_TRACE("arg1: " << arg1)
.
Constant for logging of trace informations.
#define HC_LOG_WARN |
( |
|
message | ) |
|
Constant for logging of warnings.
typedef void(* hc_log_fun_t)(int, const char *, const char *) |
A function that could be used for logging.
The first argument is the log level, the second argument is the (human readable) name of the function where this log event occured and the last argument is the message.
Get a pointer to the current active log function.
- Returns
- The current active log function (might be
NULL
).
void hc_log |
( |
int |
log_lvl, |
|
|
const char * |
function_name, |
|
|
const char * |
log_msg |
|
) |
| |
Invokes the function pointer returned by hc_get_log_fun() if not NULL.
- Parameters
-
log_lvl | One of { HC_LOG_TRACE_LVL, HC_LOG_DEBUG_LVL, HC_LOG_INFO_LVL, HC_LOG_WARN_LVL, HC_LOG_ERROR_LVL, HC_LOG_FATAL_LVL } . |
function_name | Usually __FUNCTION__ or __PRETTY_FUNCTION__ . |
log_msg | The user defined log message. |
int hc_logging_enabled |
( |
| ) |
|
Check if libHAMcast was compiled with logging enabled.
- Returns
1
if logging is enabled; otherwise 0
void hc_set_default_log_fun |
( |
int |
log_lvl | ) |
|
Get a default logging implementation (one logfile per thread).
- Parameters
-
log_lvl | The desired logging level. |
- Returns
- Set a log function that discards all log messages with
level < log_lvl
.
Set the log function to function_ptr
.
- Parameters
-
function_ptr | A custom logging implementation. |