ARX  1.0
The next-generation open source augmented reality toolkit.
Loading...
Searching...
No Matches
Macros | Typedefs | Enumerations | Functions | Variables
log.h File Reference

Logging utilities. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <sys/errno.h>
#include <ARX/ARUtil/types.h>
Include dependency graph for log.h:
This graph shows which files directly or indirectly include this file:

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_CALLBACKAR_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...
 

Detailed Description

Logging utilities.

Various routines to format and redirect log output. @Copyright 2015-2017 Daqri, LLC.

Macro Definition Documentation

◆ AR_LOG_LEVEL_DEFAULT

#define AR_LOG_LEVEL_DEFAULT   AR_LOG_LEVEL_INFO

◆ ARLOGd

#define ARLOGd (   ...)

◆ ARLOGe

#define ARLOGe (   ...)    arLog(NULL, AR_LOG_LEVEL_ERROR, __VA_ARGS__)

◆ ARLOGi

#define ARLOGi (   ...)    arLog(NULL, AR_LOG_LEVEL_INFO, __VA_ARGS__)

◆ ARLOGperror

#define ARLOGperror (   s)    arLog(NULL, AR_LOG_LEVEL_ERROR, ((s != NULL) ? "%s: %s\n" : "%s%s\n"), ((s != NULL) ? s : ""), strerror(errno))

◆ ARLOGw

#define ARLOGw (   ...)    arLog(NULL, AR_LOG_LEVEL_WARN, __VA_ARGS__)

Typedef Documentation

◆ AR_LOG_LOGGER_CALLBACK

typedef void(ARUTIL_CALLBACK * AR_LOG_LOGGER_CALLBACK) (const char *logMessage)

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
AR_LOG_LEVEL_DEBUG 
AR_LOG_LEVEL_INFO 
AR_LOG_LEVEL_WARN 
AR_LOG_LEVEL_ERROR 
AR_LOG_LEVEL_REL_INFO 

Function Documentation

◆ arLog()

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.

Parameters
tagA 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.
logLevelThe 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.
formatLog format string, in the form of printf().
See also
arLogLevel
arLogSetLogger
Here is the call graph for this function:

◆ arLogSetLogger()

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.

Parameters
callbackThe function which will be called with the log output, or NULL to cancel redirection.
callBackOnlyIfOnSameThreadIf 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.

See also
arLog

◆ arLogv()

ARUTIL_EXTERN void arLogv ( const char *  tag,
const int  logLevel,
const char *  format,
va_list  ap 
)

Variable Documentation

◆ arLogLevel

int arLogLevel
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.

See also
arLog