![]() |
ARX
1.0
The next-generation open source augmented reality toolkit.
|
Logging utilities. More...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <sys/errno.h>
#include <ARX/ARUtil/types.h>
Go to the source code of this file.
Macros | |
#define | AR_LOG_LEVEL_DEFAULT AR_LOG_LEVEL_INFO |
#define | ARLOGd(...) |
#define | ARLOGi(...) arLog(NULL, AR_LOG_LEVEL_INFO, __VA_ARGS__) |
#define | ARLOGw(...) arLog(NULL, AR_LOG_LEVEL_WARN, __VA_ARGS__) |
#define | ARLOGe(...) arLog(NULL, AR_LOG_LEVEL_ERROR, __VA_ARGS__) |
#define | ARLOGperror(s) arLog(NULL, AR_LOG_LEVEL_ERROR, ((s != NULL) ? "%s: %s\n" : "%s%s\n"), ((s != NULL) ? s : ""), strerror(errno)) |
Typedefs | |
typedef void(ARUTIL_CALLBACK * | AR_LOG_LOGGER_CALLBACK) (const char *logMessage) |
Enumerations | |
enum | { AR_LOG_LEVEL_DEBUG = 0 , AR_LOG_LEVEL_INFO , AR_LOG_LEVEL_WARN , AR_LOG_LEVEL_ERROR , AR_LOG_LEVEL_REL_INFO } |
Functions | |
ARUTIL_EXTERN void | arLog (const char *tag, const int logLevel, const char *format,...) |
Write a string to the current logging facility. More... | |
ARUTIL_EXTERN void | arLogv (const char *tag, const int logLevel, const char *format, va_list ap) |
ARUTIL_EXTERN void | arLogSetLogger (AR_LOG_LOGGER_CALLBACK callback, int callBackOnlyIfOnSameThread) |
Divert logging to a callback, or revert to default logging. More... | |
Variables | |
ARUTIL_EXTERN int | arLogLevel |
Sets the severity level. Log messages below the set severity level are not logged. More... | |
Logging utilities.
Various routines to format and redirect log output. @Copyright 2015-2017 Daqri, LLC.
#define AR_LOG_LEVEL_DEFAULT AR_LOG_LEVEL_INFO |
#define ARLOGd | ( | ... | ) |
#define ARLOGe | ( | ... | ) | arLog(NULL, AR_LOG_LEVEL_ERROR, __VA_ARGS__) |
#define ARLOGi | ( | ... | ) | arLog(NULL, AR_LOG_LEVEL_INFO, __VA_ARGS__) |
#define ARLOGperror | ( | s | ) | arLog(NULL, AR_LOG_LEVEL_ERROR, ((s != NULL) ? "%s: %s\n" : "%s%s\n"), ((s != NULL) ? s : ""), strerror(errno)) |
#define ARLOGw | ( | ... | ) | arLog(NULL, AR_LOG_LEVEL_WARN, __VA_ARGS__) |
typedef void(ARUTIL_CALLBACK * AR_LOG_LOGGER_CALLBACK) (const char *logMessage) |
anonymous enum |
ARUTIL_EXTERN void arLog | ( | const char * | tag, |
const int | logLevel, | ||
const char * | format, | ||
... | |||
) |
Write a string to the current logging facility.
The default logging facility varies by platform, but on Unix-like platforms is typically the standard error file descriptor. However, logging may be redirected to some other facility by arLogSetLogger.
Newlines are not automatically appended to log output.
tag | A tag to supply to an OS-specific logging function to specify the source of the error message. May be NULL, in which case "libAR" will be used. |
logLevel | The severity of the log message. Defined in lt;ARUtil/log.h>. Log output is written to the logging facility provided the logLevel meets or exceeds the minimum level specified in global arLogLevel. |
format | Log format string, in the form of printf(). |
ARUTIL_EXTERN void arLogSetLogger | ( | AR_LOG_LOGGER_CALLBACK | callback, |
int | callBackOnlyIfOnSameThread | ||
) |
Divert logging to a callback, or revert to default logging.
The default logging facility varies by platform, but on Unix-like platforms is typically the standard error file descriptor. However, logging may be redirected to some other facility by this function.
callback | The function which will be called with the log output, or NULL to cancel redirection. |
callBackOnlyIfOnSameThread | If non-zero, then the callback will only be called if the call to arLog is made on the same thread as the thread which called this function, and if the arLog call is made on a different thread, log output will be buffered until the next call to arLog on the original thread. |
The purpose of this is to prevent logging from secondary threads in cases where the callback model of the target platform precludes this.
ARUTIL_EXTERN void arLogv | ( | const char * | tag, |
const int | logLevel, | ||
const char * | format, | ||
va_list | ap | ||
) |
|
extern |
Sets the severity level. Log messages below the set severity level are not logged.
All calls to artoolkitX's logging facility include a "log level" parameter, which specifies the severity of the log message. (The severities are defined in <ARUtil/log.h>.) Setting this global allows for filtering of log messages. All log messages lower than the set level will not be logged by arLog(). Note that debug log messages created using the ARLOGd() macro will be logged only in debug builds, irrespective of the log level.