Audacious $Id:Doxyfile42802007-03-2104:39:00Znenolod$

log.h

Go to the documentation of this file.
00001 /*
00002  * Logging and debug mechanisms
00003  * Copyright (c) 2009 Audacious team
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; under version 3 of the License.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program.  If not, see <http://www.gnu.org/licenses>.
00016  *
00017  * The Audacious team does not consider modular code linking to
00018  * Audacious or using our public API to be a derived work.
00019  */
00027 #ifndef AUD_LOG_CTX
00028 #  define AUD_LOG_CTX NULL
00029 #endif
00030 
00031 #ifndef AUDACIOUS_LOG_H
00032 #define AUDACIOUS_LOG_H
00033 
00034 #include <glib.h>
00035 #include <stdarg.h>
00036 
00037 G_BEGIN_DECLS
00038 
00040 typedef enum {
00041     AUD_LOG_NONE = 0,       
00042     AUD_LOG_FATAL_ERROR,
00043     AUD_LOG_ERROR,
00044     AUD_LOG_WARNING,
00045     AUD_LOG_INFO,
00046     AUD_LOG_DEBUG,          
00047     AUD_LOG_DEBUG_INT,      
00048     AUD_LOG_ALL             
00049 } AudLogLevel;
00050 
00051 gint aud_log_init(const gchar *filename, const gchar *mode, gint level);
00052 void aud_log_close(void);
00053 
00054 void aud_log_add_thread_context(GThread *thread, const gchar *name);
00055 void aud_log_delete_thread_context(GThread *thread);
00056 
00057 void aud_logv(const gchar *ctx, gint level, const gchar *fmt, va_list args) __attribute__ ((format(printf, 3, 0)));
00058 void aud_log(const gchar *ctx, gint level, const gchar *fmt, ...)  __attribute__ ((format(printf, 3, 4)));
00059 void aud_log_line(const gchar *ctx, gint level, const gchar *file, const gchar *func, gint line, const gchar *fmt, ...)  __attribute__ ((format(printf, 6, 7)));
00060 
00061 
00062 /* These are here as a quick hack for transition from glib message system */
00063 //#define GLIB_COMPAT
00064 
00065 #ifdef GLIB_COMPAT
00066 #undef g_message
00067 #undef g_warning
00068 #undef g_debug
00069 #undef g_error
00070 #undef g_critical
00071 #define g_message(...) aud_log(AUD_LOG_CTX, AUD_LOG_INFO, __VA_ARGS__)
00072 #define g_warning(...) aud_log(AUD_LOG_CTX, AUD_LOG_WARNING, __VA_ARGS__)
00073 #define g_error(...) do { aud_log(AUD_LOG_CTX, AUD_LOG_ERROR, __VA_ARGS__); abort(); } while (0)
00074 #define g_critical(...) do { aud_log(AUD_LOG_CTX, AUD_LOG_ERROR, __VA_ARGS__); abort(); } while (0)
00075 #endif
00076 
00078 
00079 #if defined(DEBUG)
00080 #  define aud_message(...) aud_log_line(AUD_LOG_CTX, AUD_LOG_INFO, __FILE__, __FUNCTION__, (gint) __LINE__, __VA_ARGS__)
00081 #  define aud_warning(...) aud_log_line(AUD_LOG_CTX, AUD_LOG_WARNING, __FILE__, __FUNCTION__, (gint) __LINE__ , __VA_ARGS__)
00082 #else
00083 #  define aud_message(...) aud_log(AUD_LOG_CTX, AUD_LOG_INFO, __VA_ARGS__)
00084 #  define aud_warning(...) aud_log(AUD_LOG_CTX, AUD_LOG_WARNING, __VA_ARGS__)
00085 #endif
00086 
00087 
00089 
00090 #if defined(DEBUG)
00091 #  define AUDDBG(...) aud_log_line(AUD_LOG_CTX, AUD_LOG_DEBUG, __FILE__, __FUNCTION__, (gint) __LINE__, __VA_ARGS__)
00092 #  define aud_debug AUDDBG
00093 #  ifdef GLIB_COMPAT
00094 #    define g_debug AUDDBG
00095 #  endif
00096 #else
00097 #  define AUDDBG(...)
00098 #  define aud_debug(...)
00099 #  ifdef GLIB_COMPAT
00100 #    define g_debug
00101 #  endif
00102 #endif
00103 
00104 
00106 
00107 #if defined(DEBUG) && (DEBUG > 1)
00108 #  define AUDDBG_I(...) aud_log_line(AUD_LOG_CTX, AUD_LOG_DEBUG_INT, __FILE__, __FUNCTION__, (gint) __LINE__, __VA_ARGS__)
00109 #else
00110 #  define AUDDBG_I(...)
00111 #endif
00112 
00113 
00114 G_END_DECLS
00115 
00116 #endif /* AUDACIOUS_LOG_H */