You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by vn...@apache.org on 2018/09/26 12:44:32 UTC

[11/19] guacamole-server git commit: GUACAMOLE-623: Redirect libwebsockets logging to guacd's debug level log.

GUACAMOLE-623: Redirect libwebsockets logging to guacd's debug level log.


Project: http://git-wip-us.apache.org/repos/asf/guacamole-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/guacamole-server/commit/34f8f8b3
Tree: http://git-wip-us.apache.org/repos/asf/guacamole-server/tree/34f8f8b3
Diff: http://git-wip-us.apache.org/repos/asf/guacamole-server/diff/34f8f8b3

Branch: refs/heads/master
Commit: 34f8f8b30d84e7622005f2ba0ab704758cc88767
Parents: fe7edce
Author: Michael Jumper <mj...@apache.org>
Authored: Mon Sep 10 15:01:48 2018 -0700
Committer: Michael Jumper <mj...@apache.org>
Committed: Tue Sep 25 21:30:51 2018 -0700

----------------------------------------------------------------------
 src/protocols/kubernetes/client.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/34f8f8b3/src/protocols/kubernetes/client.c
----------------------------------------------------------------------
diff --git a/src/protocols/kubernetes/client.c b/src/protocols/kubernetes/client.c
index 77aa647..450e1e8 100644
--- a/src/protocols/kubernetes/client.c
+++ b/src/protocols/kubernetes/client.c
@@ -33,8 +33,39 @@
 
 #include <guacamole/client.h>
 
+/**
+ * Static reference to the guac_client associated with the active Kubernetes
+ * connection. As guacd guarantees that each main client connection is
+ * isolated within its own process, this is safe.
+ */
+static guac_client* guac_kubernetes_lws_log_client = NULL;
+
+/**
+ * Logging callback invoked by libwebsockets to log a single line of logging
+ * output. As libwebsockets messages are all generally low-level, the log
+ * level provided by libwebsockets is ignored here, with all messages logged
+ * instead at guacd's debug level.
+ *
+ * @param level
+ *     The libwebsockets log level associated with the log message. This value
+ *     is ignored by this implementation of the logging callback.
+ *
+ * @param line
+ *     The line of logging output to log.
+ */
+static void guac_kubernetes_log(int level, const char* line) {
+    if (guac_kubernetes_lws_log_client != NULL)
+        guac_client_log(guac_kubernetes_lws_log_client, GUAC_LOG_DEBUG,
+                "libwebsockets: %s", line);
+}
+
 int guac_client_init(guac_client* client) {
 
+    /* Redirect libwebsockets logging */
+    guac_kubernetes_lws_log_client = client;
+    lws_set_log_level(LLL_ERR | LLL_WARN | LLL_NOTICE | LLL_INFO,
+            guac_kubernetes_log);
+
     /* Set client args */
     client->args = GUAC_KUBERNETES_CLIENT_ARGS;