1 From: "vivian,zhang" <vivian.zhang@intel.com>
2 Date: Tue, 18 Jun 2013 16:20:04 +0800
3 Subject: add support for dlog - samsung
5 Change-Id: Ieddf2f3bdab50926372e9e2b5cedb2756b6cfd5c
6 Signed-off-by: Jaska Uimonen <jaska.uimonen@intel.com>
8 configure.ac | 18 +++++++++
9 src/Makefile.am | 9 +++++
10 src/daemon/cmdline.c | 8 +++-
11 src/daemon/daemon-conf.c | 10 ++++-
12 src/pulsecore/cli-command.c | 8 ++++
13 src/pulsecore/log.c | 95 +++++++++++++++++++++++++++++++++++++++++++++
14 src/pulsecore/log.h | 4 ++
15 7 files changed, 150 insertions(+), 2 deletions(-)
17 diff --git a/configure.ac b/configure.ac
18 index 9a79b36..c0beac0 100644
21 @@ -643,6 +643,24 @@ PKG_CHECK_MODULES(LIBJSON, [ json-c >= 0.11 ], [],
23 PKG_CHECK_MODULES(LIBSNDFILE, [ sndfile >= 1.0.20 ])
25 +dnl use dlog --------------------------------------------------------------------------
26 +AC_ARG_ENABLE(dlog, AC_HELP_STRING([--enable-dlog], [using dlog]),
28 + case "${enableval}" in
29 + yes) USE_DLOG=yes ;;
31 + *) AC_MSG_ERROR(bad value ${enableval} for --enable-dlog) ;;
35 +if test "x$USE_DLOG" = "xyes"; then
36 + PKG_CHECK_MODULES(DLOG, dlog)
37 + AC_SUBST(DLOG_CFLAGS)
40 +AM_CONDITIONAL(USE_DLOG, test "x$USE_DLOG" = "xyes")
41 +dnl end --------------------------------------------------------------------
45 AC_MSG_CHECKING([whether we need libatomic_ops])
46 diff --git a/src/Makefile.am b/src/Makefile.am
47 index ae841e3..3e41300 100644
50 @@ -172,6 +172,10 @@ else
51 pulseaudio_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(IMMEDIATE_LDFLAGS) -dlopen force $(foreach f,$(PREOPEN_LIBS),-dlopen $(f))
55 +pulseaudio_CFLAGS += -DUSE_DLOG
58 ###################################
60 ###################################
61 @@ -740,6 +744,11 @@ libpulsecommon_@PA_MAJORMINOR@_la_CFLAGS += $(DBUS_CFLAGS)
62 libpulsecommon_@PA_MAJORMINOR@_la_LIBADD += $(DBUS_LIBS)
66 +libpulsecommon_@PA_MAJORMINOR@_la_CFLAGS += $(DLOG_CFLAGS) -DUSE_DLOG
67 +libpulsecommon_@PA_MAJORMINOR@_la_LIBADD += $(DLOG_LIBS)
70 ###################################
72 ###################################
73 diff --git a/src/daemon/cmdline.c b/src/daemon/cmdline.c
74 index 68579c5..5bb1a0a 100644
75 --- a/src/daemon/cmdline.c
76 +++ b/src/daemon/cmdline.c
77 @@ -140,8 +140,12 @@ void pa_cmdline_help(const char *argv0) {
78 " --scache-idle-time=SECS Unload autoloaded samples when idle and\n"
80 " --log-level[=LEVEL] Increase or set verbosity level\n"
81 - " -v --verbose Increase the verbosity level\n"
82 + " -v Increase the verbosity level\n"
84 + " --log-target={auto,syslog,stderr,file:PATH,newfile:PATH,dlog,dlog-color}\n"
86 " --log-target={auto,syslog,stderr,file:PATH,newfile:PATH}\n"
88 " Specify the log target\n"
89 " --log-meta[=BOOL] Include code location in log messages\n"
90 " --log-time[=BOOL] Include timestamps in log messages\n"
91 @@ -325,6 +329,8 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d
92 if (pa_daemon_conf_set_log_target(conf, optarg) < 0) {
94 pa_log(_("Invalid log target: use either 'syslog', 'journal','stderr' or 'auto' or a valid file name 'file:<path>', 'newfile:<path>'."));
95 +#elif defined(USE_DLOG)
96 + pa_log(_("Invalid log target: use either 'syslog', 'stderr' or 'auto' or a valid file name 'file:<path>', 'newfile:<path>' or 'dlog' or 'dlog-color'."));
98 pa_log(_("Invalid log target: use either 'syslog', 'stderr' or 'auto' or a valid file name 'file:<path>', 'newfile:<path>'."));
100 diff --git a/src/daemon/daemon-conf.c b/src/daemon/daemon-conf.c
101 index ce777a6..1dde213 100644
102 --- a/src/daemon/daemon-conf.c
103 +++ b/src/daemon/daemon-conf.c
104 @@ -188,9 +188,17 @@ int pa_daemon_conf_set_log_target(pa_daemon_conf *c, const char *string) {
109 + c->log_target = log_target;
112 - c->log_target = log_target;
114 + else if (!strcmp(string, "dlog")) {
115 + c->log_target = PA_LOG_DLOG;
116 + } else if (!strcmp(string, "dlog-color")) {
117 + c->log_target = PA_LOG_DLOG_COLOR;
123 diff --git a/src/pulsecore/cli-command.c b/src/pulsecore/cli-command.c
124 index 8c956ac..2497b41 100644
125 --- a/src/pulsecore/cli-command.c
126 +++ b/src/pulsecore/cli-command.c
127 @@ -188,7 +188,11 @@ static const struct command commands[] = {
128 { "kill-client", pa_cli_command_kill_client, "Kill a client (args: index)", 2},
129 { "kill-sink-input", pa_cli_command_kill_sink_input, "Kill a sink input (args: index)", 2},
130 { "kill-source-output", pa_cli_command_kill_source_output, "Kill a source output (args: index)", 2},
132 + { "set-log-target", pa_cli_command_log_target, "Change the log target (args: null|auto|syslog|stderr|file:PATH|newfile:PATH|dlog|dlog-color)", 2},
134 { "set-log-target", pa_cli_command_log_target, "Change the log target (args: null|auto|syslog|stderr|file:PATH|newfile:PATH)", 2},
136 { "set-log-level", pa_cli_command_log_level, "Change the log level (args: numeric level)", 2},
137 { "set-log-meta", pa_cli_command_log_meta, "Show source code location in log messages (args: bool)", 2},
138 { "set-log-time", pa_cli_command_log_time, "Show timestamps in log messages (args: bool)", 2},
139 @@ -1508,7 +1512,11 @@ static int pa_cli_command_log_target(pa_core *c, pa_tokenizer *t, pa_strbuf *buf
142 if (!(m = pa_tokenizer_get(t, 1))) {
144 + pa_strbuf_puts(buf, "You need to specify a log target (null|auto|syslog|stderr|file:PATH|newfile:PATH|dlog|dlog-color).\n");
146 pa_strbuf_puts(buf, "You need to specify a log target (null|auto|syslog|stderr|file:PATH|newfile:PATH).\n");
151 diff --git a/src/pulsecore/log.c b/src/pulsecore/log.c
152 index cf96dce..dfb1d0f 100644
153 --- a/src/pulsecore/log.c
154 +++ b/src/pulsecore/log.c
161 +#define DLOG_TAG "PULSEAUDIO"
163 +#define COLOR_BLACK 30
164 +#define COLOR_RED 31
165 +#define COLOR_GREEN 32
166 +#define COLOR_BLUE 34
167 +#define COLOR_MAGENTA 35
168 +#define COLOR_CYAN 36
169 +#define COLOR_WHITE 97
170 +#define COLOR_B_GRAY 100
171 +#define COLOR_B_RED 101
172 +#define COLOR_B_GREEN 102
173 +#define COLOR_B_YELLOW 103
174 +#define COLOR_B_BLUE 104
175 +#define COLOR_B_MAGENTA 105
176 +#define COLOR_B_CYAN 106
177 +#define COLOR_REVERSE 7
180 #define ENV_LOG_SYSLOG "PULSE_LOG_SYSLOG"
181 #define ENV_LOG_LEVEL "PULSE_LOG"
182 #define ENV_LOG_COLORS "PULSE_LOG_COLORS"
183 @@ -545,6 +566,74 @@ void pa_log_levelv_meta(
189 + case PA_LOG_DLOG: {
192 + openlog(ident, LOG_PID, LOG_USER);
194 + if ((local_t = pa_utf8_to_locale(t)))
200 + SLOG (LOG_DEBUG, DLOG_TAG, "%s%s%s%s", timestamp, location, t, pa_strempty(bt));
203 + case PA_LOG_NOTICE: // no notice category in dlog, use info instead.
204 + SLOG (LOG_INFO, DLOG_TAG, "%s%s%s%s", timestamp, location, t, pa_strempty(bt));
207 + SLOG (LOG_WARN, DLOG_TAG, "%s%s%s%s", timestamp, location, t, pa_strempty(bt));
210 + SLOG (LOG_ERROR, DLOG_TAG, "%s%s%s%s", timestamp, location, t, pa_strempty(bt));
213 + SLOG (LOG_DEBUG, DLOG_TAG, "%s%s%s%s", timestamp, location, t, pa_strempty(bt));
221 + case PA_LOG_DLOG_COLOR: {
224 + openlog(ident, LOG_PID, LOG_USER);
226 + if ((local_t = pa_utf8_to_locale(t)))
232 + SLOG (LOG_DEBUG, DLOG_TAG, "\033[%dm%s%s%s%s\033[0m", COLOR_GREEN, timestamp, location, t, pa_strempty(bt));
235 + case PA_LOG_NOTICE: // no notice category in dlog, use info instead.
236 + SLOG (LOG_INFO, DLOG_TAG, "\033[%dm%s%s%s%s\033[0m", COLOR_BLUE, timestamp, location, t, pa_strempty(bt));
239 + SLOG (LOG_WARN, DLOG_TAG, "\033[%dm%s%s%s%s\033[0m", COLOR_MAGENTA, timestamp, location, t, pa_strempty(bt));
242 + SLOG (LOG_ERROR, DLOG_TAG, "\033[%dm%s%s%s%s\033[0m", COLOR_RED, timestamp, location, t, pa_strempty(bt));
245 + SLOG (LOG_DEBUG, DLOG_TAG, "%s%s%s%s", timestamp, location, t, pa_strempty(bt));
258 @@ -629,6 +718,12 @@ pa_log_target *pa_log_parse_target(const char *string) {
259 t = pa_log_target_new(PA_LOG_FILE, string + 5);
260 else if (pa_startswith(string, "newfile:"))
261 t = pa_log_target_new(PA_LOG_NEWFILE, string + 8);
263 + else if (pa_streq(string, "dlog"))
264 + t = pa_log_target_new(PA_LOG_DLOG, NULL);
265 + else if (pa_streq(string, "dlog-color"))
266 + t = pa_log_target_new(PA_LOG_DLOG_COLOR, NULL);
269 pa_log(_("Invalid log target."));
271 diff --git a/src/pulsecore/log.h b/src/pulsecore/log.h
272 index 5e9611d..031040f 100644
273 --- a/src/pulsecore/log.h
274 +++ b/src/pulsecore/log.h
275 @@ -41,6 +41,10 @@ typedef enum pa_log_target_type {
276 PA_LOG_NULL, /* to /dev/null */
277 PA_LOG_FILE, /* to a user specified file */
278 PA_LOG_NEWFILE, /* with an automatic suffix to avoid overwriting anything */
283 } pa_log_target_type_t;
285 typedef enum pa_log_level {