mirror of
https://gitlab.freedesktop.org/emersion/libliftoff.git
synced 2024-12-26 21:59:18 +01:00
feat: log disabling planes without line breaks
Enumerating all planes to be disabled makes the log unnecessary sparse. Instead just list all planes in a single line. For that introduce new API function to log something without line break in the end and adapt the log callback function pointer. BREAKING CHANGE: log callback function arguments change.
This commit is contained in:
parent
52cd24a904
commit
8028aef654
4 changed files with 23 additions and 6 deletions
5
alloc.c
5
alloc.c
|
@ -614,16 +614,17 @@ bool liftoff_output_apply(struct liftoff_output *output, drmModeAtomicReq *req)
|
|||
|
||||
/* Disable all planes. Do it before building mappings to make sure not
|
||||
to hit bandwidth limits because too many planes are enabled. */
|
||||
liftoff_log_cnt(LIFTOFF_DEBUG, "Disabling planes:");
|
||||
liftoff_list_for_each(plane, &device->planes, link) {
|
||||
if (plane->layer == NULL) {
|
||||
liftoff_log(LIFTOFF_DEBUG,
|
||||
"Disabling plane %"PRIu32, plane->id);
|
||||
liftoff_log_cnt(LIFTOFF_DEBUG, " %"PRIu32, plane->id);
|
||||
if (!plane_apply(plane, NULL, req, &compatible)) {
|
||||
return false;
|
||||
}
|
||||
assert(compatible);
|
||||
}
|
||||
}
|
||||
liftoff_log_cnt(LIFTOFF_DEBUG, "\n");
|
||||
|
||||
result.req = req;
|
||||
result.planes_len = liftoff_list_length(&device->planes);
|
||||
|
|
|
@ -74,7 +74,7 @@ enum liftoff_log_importance {
|
|||
LIFTOFF_DEBUG,
|
||||
};
|
||||
|
||||
typedef void (*liftoff_log_func)(enum liftoff_log_importance importance,
|
||||
typedef void (*liftoff_log_func)(enum liftoff_log_importance importance, bool newline,
|
||||
const char *fmt, va_list args);
|
||||
|
||||
void liftoff_log_init(enum liftoff_log_importance verbosity,
|
||||
|
|
|
@ -13,6 +13,8 @@ bool log_has(enum liftoff_log_importance verbosity);
|
|||
|
||||
void liftoff_log(enum liftoff_log_importance verbosity,
|
||||
const char *format, ...) _LIFTOFF_ATTRIB_PRINTF(2, 3);
|
||||
void liftoff_log_cnt(enum liftoff_log_importance verbosity,
|
||||
const char *format, ...) _LIFTOFF_ATTRIB_PRINTF(2, 3);
|
||||
void liftoff_log_errno(enum liftoff_log_importance verbosity, const char *msg);
|
||||
|
||||
#endif
|
||||
|
|
20
log.c
20
log.c
|
@ -5,11 +5,13 @@
|
|||
|
||||
static enum liftoff_log_importance log_importance = LIFTOFF_ERROR;
|
||||
|
||||
static void log_stderr(enum liftoff_log_importance verbosity, const char *fmt,
|
||||
static void log_stderr(enum liftoff_log_importance verbosity, bool newline, const char *fmt,
|
||||
va_list args)
|
||||
{
|
||||
vfprintf(stderr, fmt, args);
|
||||
fprintf(stderr, "\n");
|
||||
if (newline) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
static liftoff_log_func log_callback = log_stderr;
|
||||
|
@ -37,7 +39,19 @@ void liftoff_log(enum liftoff_log_importance verbosity, const char *fmt, ...)
|
|||
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
log_callback(verbosity, fmt, args);
|
||||
log_callback(verbosity, true, fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void liftoff_log_cnt(enum liftoff_log_importance verbosity, const char *fmt, ...)
|
||||
{
|
||||
if (!log_has(verbosity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
log_callback(verbosity, false, fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue