summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarius Vlad <marius.vlad@collabora.com>2020-02-12 13:08:37 +0200
committerMarius Vlad <marius.vlad@collabora.com>2020-03-04 12:18:41 +0200
commitc769a2723246f0494fb127e1ba1a70c5149db792 (patch)
tree9406714fdb7596159c1f2a4f9f75cdc2632f19f3
parenta17bac48464b5f2b6359856a75caae882d9a48f6 (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 d7de96e..f63cdaf 100644
--- a/src/main.c
+++ b/src/main.c
@@ -42,6 +42,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"
@@ -967,8 +968,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)
@@ -1118,6 +1117,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 },
@@ -1147,9 +1149,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);
@@ -1181,7 +1195,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;
@@ -1227,8 +1241,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])