| ARX 1.0 The next-generation open source augmented reality toolkit.

Loading...
Searching...
No Matches
log.h
Go to the documentation of this file.
1/*
2 * log.h
3 * artoolkitX
4 *
5 * This file is part of artoolkitX.
6 *
7 * This file is part of artoolkitX.
8 *
9 * artoolkitX is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * artoolkitX is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with artoolkitX. If not, see <http://www.gnu.org/licenses/>.
21 *
22 * As a special exception, the copyright holders of this library give you
23 * permission to link this library with independent modules to produce an
24 * executable, regardless of the license terms of these independent modules, and to
25 * copy and distribute the resulting executable under terms of your choice,
26 * provided that you also meet, for each linked independent module, the terms and
27 * conditions of the license of that module. An independent module is a module
28 * which is neither derived from nor based on this library. If you modify this
29 * library, you may extend this exception to your version of the library, but you
30 * are not obligated to do so. If you do not wish to do so, delete this exception
31 * statement from your version.
32 *
33 * Copyright 2018 Realmax, Inc.
34 * Copyright 2015-2016 Daqri, LLC.
35 * Copyright 2002-2015 ARToolworks, Inc.
36 *
37 * Author(s): Hirokazu Kato, Philip Lamb
38 *
39 */
40
49#ifndef __ARUtil_log_h__
50#define __ARUtil_log_h__
51
52#include <stdio.h>
53#include <stdlib.h>
54#include <string.h>
55#include <stdarg.h>
56#ifndef _WIN32 // errno is defined in stdlib.h on Windows.
57# ifdef EMSCRIPTEN // errno is not in sys/
58# include <errno.h>
59# else
60# include <sys/errno.h>
61# endif
62#endif
63#include <ARX/ARUtil/types.h>
64
65#ifdef __cplusplus
66 extern "C" {
67#endif
68
69 enum {
70 AR_LOG_LEVEL_DEBUG = 0,
71 AR_LOG_LEVEL_INFO,
72 AR_LOG_LEVEL_WARN,
73 AR_LOG_LEVEL_ERROR,
74 AR_LOG_LEVEL_REL_INFO
75};
76#define AR_LOG_LEVEL_DEFAULT AR_LOG_LEVEL_INFO
77
90 ARUTIL_EXTERN extern int arLogLevel;
91
110 ARUTIL_EXTERN void arLog(const char *tag, const int logLevel, const char *format, ...);
111 ARUTIL_EXTERN void arLogv(const char *tag, const int logLevel, const char *format, va_list ap);
112
113 typedef void (ARUTIL_CALLBACK *AR_LOG_LOGGER_CALLBACK)(const char *logMessage);
114
132 ARUTIL_EXTERN void arLogSetLogger(AR_LOG_LOGGER_CALLBACK callback, int callBackOnlyIfOnSameThread);
133
134#ifdef DEBUG
135# define ARLOGd(...) arLog(NULL, AR_LOG_LEVEL_DEBUG, __VA_ARGS__)
136#else
137# define ARLOGd(...)
138#endif
139#define ARLOGi(...) arLog(NULL, AR_LOG_LEVEL_INFO, __VA_ARGS__)
140#define ARLOGw(...) arLog(NULL, AR_LOG_LEVEL_WARN, __VA_ARGS__)
141#define ARLOGe(...) arLog(NULL, AR_LOG_LEVEL_ERROR, __VA_ARGS__)
142#define ARLOGperror(s) arLog(NULL, AR_LOG_LEVEL_ERROR, ((s != NULL) ? "%s: %s\n" : "%s%s\n"), ((s != NULL) ? s : ""), strerror(errno))
143
144#ifdef __cplusplus
145}
146#endif
147#endif // !__ARUtil_log_h__
AR_LOG_LEVEL_INFO
@ AR_LOG_LEVEL_INFO
Definition: log.h:71
AR_LOG_LEVEL_DEBUG
@ AR_LOG_LEVEL_DEBUG
Definition: log.h:70
AR_LOG_LEVEL_WARN
@ AR_LOG_LEVEL_WARN
Definition: log.h:72
AR_LOG_LEVEL_REL_INFO
@ AR_LOG_LEVEL_REL_INFO
Definition: log.h:74
AR_LOG_LEVEL_ERROR
@ AR_LOG_LEVEL_ERROR
Definition: log.h:73
arLog
ARUTIL_EXTERN void arLog(const char *tag, const int logLevel, const char *format,...)
Write a string to the current logging facility.
Definition: log.c:95
arLogLevel
ARUTIL_EXTERN int arLogLevel
Sets the severity level. Log messages below the set severity level are not logged.
Definition: log.c:57
arLogSetLogger
ARUTIL_EXTERN void arLogSetLogger(AR_LOG_LOGGER_CALLBACK callback, int callBackOnlyIfOnSameThread)
Divert logging to a callback, or revert to default logging.
Definition: log.c:71
arLogv
ARUTIL_EXTERN void arLogv(const char *tag, const int logLevel, const char *format, va_list ap)
Definition: log.c:106
AR_LOG_LOGGER_CALLBACK
void(ARUTIL_CALLBACK * AR_LOG_LOGGER_CALLBACK)(const char *logMessage)
Definition: log.h:113
types.h
ARUTIL_CALLBACK
#define ARUTIL_CALLBACK
Definition: types.h:59
ARUTIL_EXTERN
#define ARUTIL_EXTERN
Definition: types.h:58