2 * \brief Log message infrastructure
5 * Copyright (c) 2004 Lutz Mueller <lutz@users.sourceforge.net>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301 USA.
23 #ifndef __EXIF_LOG_H__
24 #define __EXIF_LOG_H__
28 #endif /* __cplusplus */
30 #include <libexif/exif-mem.h>
33 /*! State maintained by the logging interface */
34 typedef struct _ExifLog ExifLog;
36 /*! Create a new logging instance.
39 * \return new instance of #ExifLog
41 ExifLog *exif_log_new (void);
42 ExifLog *exif_log_new_mem (ExifMem *);
43 void exif_log_ref (ExifLog *log);
44 void exif_log_unref (ExifLog *log);
46 /*! Delete instance of #ExifLog.
49 * \param[in] log #ExifLog
50 * \return new instance of #ExifLog
52 void exif_log_free (ExifLog *log);
57 EXIF_LOG_CODE_NO_MEMORY,
58 EXIF_LOG_CODE_CORRUPT_DATA
61 /*! Return a textual description of the given class of error log.
63 * \param[in] code logging message class
64 * \return textual description of the log class
66 const char *exif_log_code_get_title (ExifLogCode code);
68 /*! Return a verbose description of the given class of error log.
70 * \param[in] code logging message class
71 * \return verbose description of the log class
73 const char *exif_log_code_get_message (ExifLogCode code);
75 /*! Log callback function prototype.
77 typedef void (* ExifLogFunc) (ExifLog *log, ExifLogCode, const char *domain,
78 const char *format, va_list args, void *data);
80 /*! Register log callback function.
81 * Calls to the log callback function are purely for diagnostic purposes.
83 * \param[in] log logging state variable
84 * \param[in] func callback function to set
85 * \param[in] data data to pass into callback function
87 void exif_log_set_func (ExifLog *log, ExifLogFunc func, void *data);
89 #ifndef NO_VERBOSE_TAG_STRINGS
90 void exif_log (ExifLog *log, ExifLogCode, const char *domain,
91 const char *format, ...)
93 __attribute__((__format__(printf,4,5)))
97 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
98 #define exif_log(...) do { } while (0)
99 #elif defined(__GNUC__)
100 #define exif_log(x...) do { } while (0)
102 #define exif_log (void)
106 void exif_logv (ExifLog *log, ExifLogCode, const char *domain,
107 const char *format, va_list args);
109 /* For your convenience */
110 #define EXIF_LOG_NO_MEMORY(l,d,s) exif_log ((l), EXIF_LOG_CODE_NO_MEMORY, (d), "Could not allocate %lu byte(s).", (unsigned long)(s))
114 #endif /* __cplusplus */
116 #endif /* __EXIF_LOG_H__ */