2004-09-05 00:03:16 +00:00
|
|
|
#ifndef foologhfoo
|
|
|
|
|
#define foologhfoo
|
|
|
|
|
|
2004-11-21 21:31:28 +00:00
|
|
|
/***
|
2006-06-19 21:53:48 +00:00
|
|
|
This file is part of PulseAudio.
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2007-02-13 15:35:19 +00:00
|
|
|
Copyright 2004-2006 Lennart Poettering
|
|
|
|
|
Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
|
|
|
|
|
2006-06-19 21:53:48 +00:00
|
|
|
PulseAudio is free software; you can redistribute it and/or modify
|
2004-11-21 21:31:28 +00:00
|
|
|
it under the terms of the GNU Lesser General Public License as published
|
2009-03-03 20:23:02 +00:00
|
|
|
by the Free Software Foundation; either version 2.1 of the License,
|
2004-11-21 21:31:28 +00:00
|
|
|
or (at your option) any later version.
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2006-06-19 21:53:48 +00:00
|
|
|
PulseAudio is distributed in the hope that it will be useful, but
|
2004-11-21 21:31:28 +00:00
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
General Public License for more details.
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2004-11-21 21:31:28 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
2006-06-19 21:53:48 +00:00
|
|
|
along with PulseAudio; if not, write to the Free Software
|
2004-11-21 21:31:28 +00:00
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
|
USA.
|
|
|
|
|
***/
|
|
|
|
|
|
2004-12-11 00:10:41 +00:00
|
|
|
#include <stdarg.h>
|
2006-08-18 21:26:01 +00:00
|
|
|
#include <stdlib.h>
|
2008-10-21 19:13:15 +02:00
|
|
|
|
|
|
|
|
#include <pulsecore/macro.h>
|
2008-05-15 23:34:41 +00:00
|
|
|
#include <pulse/gccmacro.h>
|
2004-09-05 00:03:16 +00:00
|
|
|
|
2004-11-21 21:31:28 +00:00
|
|
|
/* A simple logging subsystem */
|
|
|
|
|
|
|
|
|
|
/* Where to log to */
|
2006-01-11 01:17:39 +00:00
|
|
|
typedef enum pa_log_target {
|
2004-11-21 21:31:28 +00:00
|
|
|
PA_LOG_STDERR, /* default */
|
2004-09-05 00:03:16 +00:00
|
|
|
PA_LOG_SYSLOG,
|
2009-02-21 22:45:56 +01:00
|
|
|
PA_LOG_NULL, /* to /dev/null */
|
|
|
|
|
PA_LOG_TARGET_MAX
|
2006-01-27 16:25:31 +00:00
|
|
|
} pa_log_target_t;
|
2004-09-05 00:03:16 +00:00
|
|
|
|
2006-01-11 01:17:39 +00:00
|
|
|
typedef enum pa_log_level {
|
2004-12-11 00:10:41 +00:00
|
|
|
PA_LOG_ERROR = 0, /* Error messages */
|
|
|
|
|
PA_LOG_WARN = 1, /* Warning messages */
|
|
|
|
|
PA_LOG_NOTICE = 2, /* Notice messages */
|
|
|
|
|
PA_LOG_INFO = 3, /* Info messages */
|
|
|
|
|
PA_LOG_DEBUG = 4, /* debug message */
|
|
|
|
|
PA_LOG_LEVEL_MAX
|
2006-01-27 16:25:31 +00:00
|
|
|
} pa_log_level_t;
|
2004-12-11 00:10:41 +00:00
|
|
|
|
2009-02-21 22:45:56 +01:00
|
|
|
typedef enum pa_log_flags {
|
|
|
|
|
PA_LOG_COLORS = 0x01, /* Show colorful output */
|
|
|
|
|
PA_LOG_PRINT_TIME = 0x02, /* Show time */
|
|
|
|
|
PA_LOG_PRINT_FILE = 0x04, /* Show source file */
|
|
|
|
|
PA_LOG_PRINT_META = 0x08, /* Show extended locaton information */
|
|
|
|
|
PA_LOG_PRINT_LEVEL = 0x10, /* Show log level prefix */
|
|
|
|
|
} pa_log_flags_t;
|
|
|
|
|
|
|
|
|
|
typedef enum pa_log_merge {
|
|
|
|
|
PA_LOG_SET,
|
|
|
|
|
PA_LOG_UNSET,
|
|
|
|
|
PA_LOG_RESET
|
|
|
|
|
} pa_log_merge_t;
|
|
|
|
|
|
2006-01-11 01:17:39 +00:00
|
|
|
/* Set an identification for the current daemon. Used when logging to syslog. */
|
2004-09-05 00:03:16 +00:00
|
|
|
void pa_log_set_ident(const char *p);
|
2004-11-21 21:31:28 +00:00
|
|
|
|
2009-02-21 22:45:56 +01:00
|
|
|
/* Set a log target. */
|
|
|
|
|
void pa_log_set_target(pa_log_target_t t);
|
2004-12-11 00:10:41 +00:00
|
|
|
|
2008-10-21 19:13:15 +02:00
|
|
|
/* Maximal log level */
|
2009-02-21 22:45:56 +01:00
|
|
|
void pa_log_set_level(pa_log_level_t l);
|
|
|
|
|
|
|
|
|
|
/* Set flags */
|
|
|
|
|
void pa_log_set_flags(pa_log_flags_t flags, pa_log_merge_t merge);
|
|
|
|
|
|
|
|
|
|
/* Enable backtrace */
|
2008-10-21 19:13:15 +02:00
|
|
|
void pa_log_set_show_backtrace(unsigned nlevels);
|
2004-11-21 21:31:28 +00:00
|
|
|
|
2006-08-18 21:26:01 +00:00
|
|
|
void pa_log_level_meta(
|
|
|
|
|
pa_log_level_t level,
|
|
|
|
|
const char*file,
|
|
|
|
|
int line,
|
|
|
|
|
const char *func,
|
|
|
|
|
const char *format, ...) PA_GCC_PRINTF_ATTR(5,6);
|
2009-02-21 22:45:56 +01:00
|
|
|
|
2006-08-18 21:26:01 +00:00
|
|
|
void pa_log_levelv_meta(
|
|
|
|
|
pa_log_level_t level,
|
|
|
|
|
const char*file,
|
|
|
|
|
int line,
|
|
|
|
|
const char *func,
|
|
|
|
|
const char *format,
|
|
|
|
|
va_list ap);
|
2004-12-11 00:10:41 +00:00
|
|
|
|
2009-02-21 22:45:56 +01:00
|
|
|
void pa_log_level(
|
|
|
|
|
pa_log_level_t level,
|
|
|
|
|
const char *format, ...) PA_GCC_PRINTF_ATTR(2,3);
|
|
|
|
|
|
|
|
|
|
void pa_log_levelv(
|
|
|
|
|
pa_log_level_t level,
|
|
|
|
|
const char *format,
|
|
|
|
|
va_list ap);
|
2004-12-11 00:10:41 +00:00
|
|
|
|
2006-08-18 21:26:01 +00:00
|
|
|
#if __STDC_VERSION__ >= 199901L
|
|
|
|
|
|
|
|
|
|
/* ISO varargs available */
|
|
|
|
|
|
|
|
|
|
#define pa_log_debug(...) pa_log_level_meta(PA_LOG_DEBUG, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
|
|
|
|
#define pa_log_info(...) pa_log_level_meta(PA_LOG_INFO, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
|
|
|
|
#define pa_log_notice(...) pa_log_level_meta(PA_LOG_NOTICE, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
|
|
|
|
#define pa_log_warn(...) pa_log_level_meta(PA_LOG_WARN, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
|
|
|
|
#define pa_log_error(...) pa_log_level_meta(PA_LOG_ERROR, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
|
|
#define LOG_FUNC(suffix, level) \
|
|
|
|
|
PA_GCC_UNUSED static void pa_log_##suffix(const char *format, ...) { \
|
|
|
|
|
va_list ap; \
|
|
|
|
|
va_start(ap, format); \
|
|
|
|
|
pa_log_levelv_meta(level, NULL, 0, NULL, format, ap); \
|
|
|
|
|
va_end(ap); \
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LOG_FUNC(debug, PA_LOG_DEBUG)
|
|
|
|
|
LOG_FUNC(info, PA_LOG_INFO)
|
|
|
|
|
LOG_FUNC(notice, PA_LOG_NOTICE)
|
|
|
|
|
LOG_FUNC(warn, PA_LOG_WARN)
|
|
|
|
|
LOG_FUNC(error, PA_LOG_ERROR)
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
2004-12-11 00:10:41 +00:00
|
|
|
#define pa_log pa_log_error
|
2004-09-05 00:03:16 +00:00
|
|
|
|
2009-01-23 23:58:57 +01:00
|
|
|
pa_bool_t pa_log_ratelimit(void);
|
|
|
|
|
|
2004-09-05 00:03:16 +00:00
|
|
|
#endif
|