aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarius Vlad <marius.vlad@collabora.com>2020-02-12 13:08:37 +0200
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>2020-02-17 14:43:35 +0000
commitad413711dab65ced91ad7d51abe23bc8c86207e5 (patch)
tree817bc6ece9f3f48a15d623415d62fa539a2708f3
parentc33644e558bc32dbfc8afb53e010325cc62c2858 (diff)
main: Add support for the logging context when creating the compositor
instance The logging context was added in weston 7, but we didn't had supporting code for it. This creates a logging context, a logging log scope, and a logger subscriber. Bug-AGL: SPEC-3180 Signed-off-by: Marius Vlad <marius.vlad@collabora.com> Change-Id: I3f5687fc3b68b79e3fd37a100fd6fa1f3bc1a2ae
-rw-r--r--src/main.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/main.c b/src/main.c
index 519d427..e1ebab5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -44,6 +44,7 @@
#include <libweston/libweston.h>
#include <libweston/windowed-output-api.h>
#include <libweston/config-parser.h>
+#include <libweston/weston-log.h>
#include "shared/os-compatibility.h"
@@ -977,8 +978,6 @@ load_config(struct weston_config **config, bool no_config,
}
static FILE *logfile;
-//static struct weston_log_scope *log_scope;
-//static struct weston_log_scope *protocol_scope;
static int
log_timestamp(void)
@@ -1128,6 +1127,9 @@ int main(int argc, char *argv[])
int no_config = 0;
char *config_file = NULL;
int debug_protocol = 0;
+ struct weston_log_context *log_ctx = NULL;
+ struct weston_log_scope *log_scope;
+ struct weston_log_subscriber *logger;
const struct weston_option core_options[] = {
{ WESTON_OPTION_STRING, "backend", 'B', &backend },
@@ -1157,9 +1159,21 @@ int main(int argc, char *argv[])
return EXIT_SUCCESS;
}
+ log_ctx = weston_log_ctx_compositor_create();
+ if (!log_ctx) {
+ fprintf(stderr, "Failed to initialize weston debug framework.\n");
+ return EXIT_FAILURE;
+ }
+
+ log_scope = weston_compositor_add_log_scope(log_ctx, "log",
+ "agl-compositor log\n",
+ NULL, NULL);
+
log_file_open(log);
weston_log_set_handler(vlog, vlog_continue);
+ logger = weston_log_subscriber_create_log(logfile);
+
if (load_config(&ivi.config, no_config, config_file) < 0)
goto error_signals;
section = weston_config_get_section(ivi.config, "core", NULL, NULL);
@@ -1191,7 +1205,7 @@ int main(int argc, char *argv[])
if (!signals[i])
goto error_signals;
- ivi.compositor = weston_compositor_create(display, &ivi);
+ ivi.compositor = weston_compositor_create(display, log_ctx, &ivi);
if (!ivi.compositor) {
weston_log("fatal: failed to create compositor.\n");
goto error_signals;
@@ -1237,8 +1251,16 @@ int main(int argc, char *argv[])
wl_display_destroy_clients(display);
error_compositor:
+ weston_compositor_tear_down(ivi.compositor);
+
+ weston_compositor_log_scope_destroy(log_scope);
+ log_scope = NULL;
+
+ weston_log_ctx_compositor_destroy(ivi.compositor);
weston_compositor_destroy(ivi.compositor);
+ weston_log_subscriber_destroy_log(logger);
+
error_signals:
for (size_t i = 0; i < ARRAY_LENGTH(signals); ++i)
if (signals[i])