Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
wireplumber
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pkg
wireplumber
Commits
ecbcabdc
Commit
ecbcabdc
authored
4 years ago
by
George Kiagiadakis
Browse files
Options
Downloads
Patches
Plain Diff
debug: add support for redirecting pipewire's log to the glib one
parent
c80b8720
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/wp/debug.c
+80
-8
80 additions, 8 deletions
lib/wp/debug.c
lib/wp/debug.h
+3
-0
3 additions, 0 deletions
lib/wp/debug.h
with
83 additions
and
8 deletions
lib/wp/debug.c
+
80
−
8
View file @
ecbcabdc
...
...
@@ -8,6 +8,7 @@
#include
"debug.h"
#include
<pipewire/pipewire.h>
#include
<spa/support/log.h>
static
gsize
initialized
=
0
;
static
gboolean
use_color
=
FALSE
;
...
...
@@ -55,18 +56,19 @@ struct common_fields
*/
static
const
struct
{
GLogLevelFlags
log_level
;
enum
spa_log_level
spa_level
;
gchar
name
[
6
];
gchar
priority
[
2
];
gchar
color
[
8
];
}
log_level_info
[]
=
{
{
0
,
"UNK "
,
"5"
,
COLOR_BRIGHT_RED
},
{
G_LOG_LEVEL_ERROR
,
"ERROR"
,
"3"
,
COLOR_RED
},
{
G_LOG_LEVEL_CRITICAL
,
"CRIT "
,
"4"
,
COLOR_BRIGHT_MAGENTA
},
{
G_LOG_LEVEL_WARNING
,
"WARN "
,
"4"
,
COLOR_BRIGHT_YELLOW
},
{
G_LOG_LEVEL_MESSAGE
,
"MSG "
,
"5"
,
COLOR_BRIGHT_GREEN
},
{
G_LOG_LEVEL_INFO
,
"INFO "
,
"6"
,
COLOR_GREEN
},
{
G_LOG_LEVEL_DEBUG
,
"DEBUG"
,
"7"
,
COLOR_CYAN
},
{
WP_LOG_LEVEL_TRACE
,
"TRACE"
,
"7"
,
COLOR_YELLOW
},
{
0
,
0
,
"UNK "
,
"5"
,
COLOR_BRIGHT_RED
},
{
G_LOG_LEVEL_ERROR
,
SPA_LOG_LEVEL_ERROR
,
"ERROR"
,
"3"
,
COLOR_RED
},
{
G_LOG_LEVEL_CRITICAL
,
0
,
"CRIT "
,
"4"
,
COLOR_BRIGHT_MAGENTA
},
{
G_LOG_LEVEL_WARNING
,
SPA_LOG_LEVEL_WARN
,
"WARN "
,
"4"
,
COLOR_BRIGHT_YELLOW
},
{
G_LOG_LEVEL_MESSAGE
,
0
,
"MSG "
,
"5"
,
COLOR_BRIGHT_GREEN
},
{
G_LOG_LEVEL_INFO
,
SPA_LOG_LEVEL_INFO
,
"INFO "
,
"6"
,
COLOR_GREEN
},
{
G_LOG_LEVEL_DEBUG
,
SPA_LOG_LEVEL_DEBUG
,
"DEBUG"
,
"7"
,
COLOR_CYAN
},
{
WP_LOG_LEVEL_TRACE
,
SPA_LOG_LEVEL_TRACE
,
"TRACE"
,
"7"
,
COLOR_YELLOW
},
};
/* map glib's log levels, which are flags in the range (1<<2) to (1<<8),
...
...
@@ -81,6 +83,15 @@ log_level_index (GLogLevelFlags log_level)
return
(
logarithm
>=
2
&&
logarithm
<=
8
)
?
(
logarithm
-
1
)
:
0
;
}
static
inline
gint
spa_log_level_index
(
enum
spa_log_level
lvl
)
{
for
(
gint
i
=
1
;
i
<
SPA_N_ELEMENTS
(
log_level_info
);
i
++
)
if
(
lvl
==
log_level_info
[
i
].
spa_level
)
return
i
;
return
0
;
}
static
void
wp_debug_initialize
(
void
)
{
...
...
@@ -319,3 +330,64 @@ wp_log_structured_standard (
g_log_structured_array
(
log_level
,
fields
,
n_fields
);
}
static
void
wp_spa_log_logv
(
void
*
object
,
enum
spa_log_level
level
,
const
char
*
file
,
int
line
,
const
char
*
func
,
const
char
*
fmt
,
va_list
args
)
{
g_autofree
gchar
*
message
=
NULL
;
gchar
line_str
[
11
];
GLogField
fields
[]
=
{
{
"PRIORITY"
,
NULL
,
-
1
},
{
"CODE_FILE"
,
file
,
-
1
},
{
"CODE_LINE"
,
line_str
,
-
1
},
{
"CODE_FUNC"
,
func
,
-
1
},
{
"MESSAGE"
,
NULL
,
-
1
},
{
"GLIB_DOMAIN"
,
"pw-lib"
,
-
1
},
};
gint
log_level_idx
=
spa_log_level_index
(
level
);
GLogLevelFlags
log_level
=
log_level_info
[
log_level_idx
].
log_level
;
fields
[
0
].
value
=
log_level_info
[
log_level_idx
].
priority
;
sprintf
(
line_str
,
"%d"
,
line
);
fields
[
4
].
value
=
message
=
g_strdup_vprintf
(
fmt
,
args
);
g_log_structured_array
(
log_level
,
fields
,
SPA_N_ELEMENTS
(
fields
));
}
static
void
wp_spa_log_log
(
void
*
object
,
enum
spa_log_level
level
,
const
char
*
file
,
int
line
,
const
char
*
func
,
const
char
*
fmt
,
...)
{
va_list
args
;
va_start
(
args
,
fmt
);
wp_spa_log_logv
(
object
,
level
,
file
,
line
,
func
,
fmt
,
args
);
va_end
(
args
);
}
static
const
struct
spa_log_methods
wp_spa_log_methods
=
{
SPA_VERSION_LOG_METHODS
,
.
log
=
wp_spa_log_log
,
.
logv
=
wp_spa_log_logv
,
};
static
struct
spa_log
wp_spa_log
=
{
.
iface
=
{
SPA_TYPE_INTERFACE_Log
,
SPA_VERSION_LOG
,
{
&
wp_spa_log_methods
,
NULL
}
},
.
level
=
SPA_LOG_LEVEL_INFO
,
};
void
wp_install_glib_pw_log
(
void
)
{
pw_log_set
(
&
wp_spa_log
);
}
This diff is collapsed.
Click to expand it.
lib/wp/debug.h
+
3
−
0
View file @
ecbcabdc
...
...
@@ -72,6 +72,9 @@ void wp_log_structured_standard (const gchar *log_domain,
#define wp_trace_boxed(type, object, ...) \
wp_log (WP_LOG_LEVEL_TRACE, type, object, __VA_ARGS__)
WP_API
void
wp_install_glib_pw_log
(
void
);
G_END_DECLS
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment