Pārlūkot izejas kodu

Logging: Make logging a proper plugin with state and cleanup method

Julius Pfrommer 5 gadi atpakaļ
vecāks
revīzija
89f728aee1
49 mainītis faili ar 556 papildinājumiem un 500 dzēšanām
  1. 19 20
      arch/ua_network_tcp.c
  2. 6 5
      arch/ua_network_tcp.h
  3. 6 5
      examples/client_connect_loop.c
  4. 4 4
      examples/client_connectivitycheck_loop.c
  5. 25 17
      examples/client_subscription_loop.c
  6. 3 5
      examples/discovery/client_find_servers.c
  7. 25 23
      examples/discovery/server_multicast.c
  8. 8 9
      examples/discovery/server_register.c
  9. 2 1
      examples/pubsub/tutorial_pubsub_connection.c
  10. 1 2
      examples/server.cpp
  11. 2 4
      examples/server_certificate.c
  12. 0 2
      examples/server_udp.c
  13. 33 20
      include/ua_plugin_log.h
  14. 1 1
      include/ua_plugin_network.h
  15. 7 6
      include/ua_plugin_securitypolicy.h
  16. 8 8
      plugins/ua_config_default.c
  17. 17 9
      plugins/ua_log_stdout.c
  18. 11 4
      plugins/ua_log_stdout.h
  19. 3 3
      plugins/ua_securitypolicies.h
  20. 4 3
      plugins/ua_securitypolicy_basic128rsa15.c
  21. 4 3
      plugins/ua_securitypolicy_basic256sha256.c
  22. 3 2
      plugins/ua_securitypolicy_none.c
  23. 16 15
      src/client/ua_client.c
  24. 18 18
      src/client/ua_client_connect.c
  25. 28 31
      src/client/ua_client_connect_async.c
  26. 22 20
      src/client/ua_client_subscriptions.c
  27. 18 11
      src/pubsub/ua_pubsub.c
  28. 10 10
      src/pubsub/ua_pubsub_manager.c
  29. 13 8
      src/pubsub/ua_pubsub_ns0.c
  30. 1 1
      src/server/ua_discovery_manager.c
  31. 5 5
      src/server/ua_securechannel_manager.c
  32. 4 5
      src/server/ua_server.c
  33. 24 23
      src/server/ua_server_binary.c
  34. 2 2
      src/server/ua_server_discovery.c
  35. 8 8
      src/server/ua_server_discovery_mdns.c
  36. 2 2
      src/server/ua_server_ns0.c
  37. 15 14
      src/server/ua_services_attribute.c
  38. 19 19
      src/server/ua_services_discovery.c
  39. 20 20
      src/server/ua_services_discovery_multicast.c
  40. 55 53
      src/server/ua_services_nodemanagement.c
  41. 5 5
      src/server/ua_services_securechannel.c
  42. 11 11
      src/server/ua_services_session.c
  43. 25 21
      src/server/ua_services_subscription.c
  44. 5 5
      src/server/ua_session_manager.c
  45. 18 17
      src/server/ua_subscription.c
  46. 4 4
      src/server/ua_subscription_datachange.c
  47. 13 13
      src/server/ua_subscription_events.c
  48. 1 1
      src/server/ua_subscription_monitoreditem.c
  49. 2 2
      tests/fuzz/ua_debug_dump_pkgs_file.c

+ 19 - 20
arch/ua_network_tcp.c

@@ -166,7 +166,7 @@ typedef struct ConnectionEntry {
 } ConnectionEntry;
 
 typedef struct {
-    UA_Logger logger;
+    const UA_Logger *logger;
     UA_UInt16 port;
     UA_SOCKET serverSockets[FD_SETSIZE];
     UA_UInt16 serverSocketsSize;
@@ -410,7 +410,7 @@ ServerNetworkLayerTCP_listen(UA_ServerNetworkLayer *nl, UA_Server *server,
     if (UA_select(highestfd+1, &fdset, NULL, &errset, &tmptv) < 0) {
         UA_LOG_SOCKET_ERRNO_WRAP(
             UA_LOG_WARNING(layer->logger, UA_LOGCATEGORY_NETWORK,
-                                  "Socket select failed with %s", errno_str));
+                           "Socket select failed with %s", errno_str));
         // we will retry, so do not return bad
         return UA_STATUSCODE_GOOD;
     }
@@ -522,7 +522,8 @@ ServerNetworkLayerTCP_deleteMembers(UA_ServerNetworkLayer *nl) {
 }
 
 UA_ServerNetworkLayer
-UA_ServerNetworkLayerTCP(UA_ConnectionConfig config, UA_UInt16 port, UA_Logger logger) {
+UA_ServerNetworkLayerTCP(UA_ConnectionConfig config, UA_UInt16 port,
+                         const UA_Logger *logger) {
     UA_ServerNetworkLayer nl;
     memset(&nl, 0, sizeof(UA_ServerNetworkLayer));
     nl.deleteMembers = ServerNetworkLayerTCP_deleteMembers;
@@ -613,18 +614,18 @@ UA_StatusCode UA_ClientConnectionTCP_poll(UA_Client *client, void *data) {
     connection->sockfd = (UA_Int32) clientsockfd; /* cast for win32 */
 
     if(clientsockfd == UA_INVALID_SOCKET) {
-            UA_LOG_WARNING(UA_Log_Stdout, UA_LOGCATEGORY_NETWORK,
-                            "Could not create client socket: %s", strerror(UA_ERRNO));
-            ClientNetworkLayerTCP_close(connection);
-            return UA_STATUSCODE_BADDISCONNECT;
+        UA_LOG_WARNING(UA_Log_Stdout, UA_LOGCATEGORY_NETWORK,
+                       "Could not create client socket: %s", strerror(UA_ERRNO));
+        ClientNetworkLayerTCP_close(connection);
+        return UA_STATUSCODE_BADDISCONNECT;
     }
 
     /* Non blocking connect to be able to timeout */
-    if (UA_socket_set_nonblocking(clientsockfd) != UA_STATUSCODE_GOOD) {
-            UA_LOG_WARNING(UA_Log_Stdout, UA_LOGCATEGORY_NETWORK,
-                            "Could not set the client socket to nonblocking");
-            ClientNetworkLayerTCP_close(connection);
-            return UA_STATUSCODE_BADDISCONNECT;
+    if(UA_socket_set_nonblocking(clientsockfd) != UA_STATUSCODE_GOOD) {
+        UA_LOG_WARNING(UA_Log_Stdout, UA_LOGCATEGORY_NETWORK,
+                       "Could not set the client socket to nonblocking");
+        ClientNetworkLayerTCP_close(connection);
+        return UA_STATUSCODE_BADDISCONNECT;
     }
 
     /* Non blocking connect */
@@ -634,7 +635,7 @@ UA_StatusCode UA_ClientConnectionTCP_poll(UA_Client *client, void *data) {
     if ((error == -1) && (UA_ERRNO != UA_ERR_CONNECTION_PROGRESS)) {
             ClientNetworkLayerTCP_close(connection);
             UA_LOG_WARNING(UA_Log_Stdout, UA_LOGCATEGORY_NETWORK,
-                            "Connection to  failed with error: %s", strerror(UA_ERRNO));
+                           "Connection to  failed with error: %s", strerror(UA_ERRNO));
             return UA_STATUSCODE_BADDISCONNECT;
     }
 
@@ -732,9 +733,9 @@ UA_StatusCode UA_ClientConnectionTCP_poll(UA_Client *client, void *data) {
 
 }
 
-UA_Connection UA_ClientConnectionTCP_init(UA_ConnectionConfig config,
-		const char *endpointUrl, const UA_UInt32 timeout,
-                UA_Logger logger) {
+UA_Connection
+UA_ClientConnectionTCP_init(UA_ConnectionConfig config, const char *endpointUrl,
+                            const UA_UInt32 timeout, const UA_Logger *logger) {
     UA_Connection connection;
     memset(&connection, 0, sizeof(UA_Connection));
 
@@ -793,10 +794,8 @@ UA_Connection UA_ClientConnectionTCP_init(UA_ConnectionConfig config,
 }
 
 UA_Connection
-UA_ClientConnectionTCP(UA_ConnectionConfig config,
-                       const char *endpointUrl, const UA_UInt32 timeout,
-                       UA_Logger logger) {
-
+UA_ClientConnectionTCP(UA_ConnectionConfig config, const char *endpointUrl,
+                       const UA_UInt32 timeout, const UA_Logger *logger) {
     UA_initialize_architecture_network();
 
     if(logger == NULL) {

+ 6 - 5
arch/ua_network_tcp.h

@@ -16,15 +16,16 @@ extern "C" {
 #include "ua_plugin_log.h"
 
 UA_ServerNetworkLayer UA_EXPORT
-UA_ServerNetworkLayerTCP(UA_ConnectionConfig conf, UA_UInt16 port, UA_Logger logger);
+UA_ServerNetworkLayerTCP(UA_ConnectionConfig conf, UA_UInt16 port, const UA_Logger *logger);
 
 UA_Connection UA_EXPORT
-UA_ClientConnectionTCP(UA_ConnectionConfig conf, const char *endpointUrl, const UA_UInt32 timeout,
-                       UA_Logger logger);
+UA_ClientConnectionTCP(UA_ConnectionConfig conf, const char *endpointUrl,
+                       const UA_UInt32 timeout, const UA_Logger *logger);
 
 UA_StatusCode UA_ClientConnectionTCP_poll(UA_Client *client, void *data);
-UA_Connection UA_EXPORT UA_ClientConnectionTCP_init(UA_ConnectionConfig conf,
-                const char *endpointUrl, const UA_UInt32 timeout, UA_Logger logger);
+UA_Connection UA_EXPORT
+UA_ClientConnectionTCP_init(UA_ConnectionConfig conf, const char *endpointUrl,
+                            const UA_UInt32 timeout, const UA_Logger *logger);
 #ifdef __cplusplus
 } // extern "C"
 #endif

+ 6 - 5
examples/client_connect_loop.c

@@ -14,10 +14,9 @@
 #include <signal.h>
 
 UA_Boolean running = true;
-UA_Logger logger = UA_Log_Stdout;
 
 static void stopHandler(int sign) {
-    UA_LOG_INFO(logger, UA_LOGCATEGORY_CLIENT, "Received Ctrl-C");
+    UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_CLIENT, "Received Ctrl-C");
     running = 0;
 }
 
@@ -41,7 +40,7 @@ int main(void) {
         /* Alternatively you can also use UA_Client_getState to get the current state */
         UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
         if(retval != UA_STATUSCODE_GOOD) {
-            UA_LOG_ERROR(logger, UA_LOGCATEGORY_CLIENT, "Not connected. Retrying to connect in 1 second");
+            UA_LOG_ERROR(UA_Log_Stdout, UA_LOGCATEGORY_CLIENT, "Not connected. Retrying to connect in 1 second");
             /* The connect may timeout after 1 second (see above) or it may fail immediately on network errors */
             /* E.g. name resolution errors or unreachable network. Thus there should be a small sleep here */
             UA_sleep_ms(1000);
@@ -54,14 +53,16 @@ int main(void) {
 
         retval = UA_Client_readValueAttribute(client, nodeId, &value);
         if(retval == UA_STATUSCODE_BADCONNECTIONCLOSED) {
-            UA_LOG_ERROR(logger, UA_LOGCATEGORY_CLIENT, "Connection was closed. Reconnecting ...");
+            UA_LOG_ERROR(UA_Log_Stdout, UA_LOGCATEGORY_CLIENT,
+                         "Connection was closed. Reconnecting ...");
             continue;
         }
         if(retval == UA_STATUSCODE_GOOD &&
            UA_Variant_hasScalarType(&value, &UA_TYPES[UA_TYPES_DATETIME])) {
             UA_DateTime raw_date = *(UA_DateTime *) value.data;
             UA_DateTimeStruct dts = UA_DateTime_toStruct(raw_date);
-            UA_LOG_INFO(logger, UA_LOGCATEGORY_USERLAND, "date is: %02u-%02u-%04u %02u:%02u:%02u.%03u",
+            UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,
+                        "date is: %02u-%02u-%04u %02u:%02u:%02u.%03u",
                         dts.day, dts.month, dts.year, dts.hour, dts.min, dts.sec, dts.milliSec);
         }
         UA_Variant_deleteMembers(&value);

+ 4 - 4
examples/client_connectivitycheck_loop.c

@@ -5,16 +5,15 @@
 #include <signal.h>
 
 UA_Boolean running = true;
-UA_Logger logger = UA_Log_Stdout;
 
 static void stopHandler(int sign) {
-    UA_LOG_INFO(logger, UA_LOGCATEGORY_USERLAND, "Received Ctrl-C");
+    UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND, "Received Ctrl-C");
     running = 0;
 }
 
 static void
 inactivityCallback (UA_Client *client) {
-    UA_LOG_INFO(logger, UA_LOGCATEGORY_USERLAND, "Server Inactivity");
+    UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND, "Server Inactivity");
 }
 
 int main(void) {
@@ -36,7 +35,8 @@ int main(void) {
         /* Alternatively you can also use UA_Client_getState to get the current state */
         UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
         if(retval != UA_STATUSCODE_GOOD) {
-            UA_LOG_ERROR(logger, UA_LOGCATEGORY_USERLAND, "Not connected. Retrying to connect in 1 second");
+            UA_LOG_ERROR(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,
+                         "Not connected. Retrying to connect in 1 second");
             /* The connect may timeout after 1 second (see above) or it may fail immediately on network errors */
             /* E.g. name resolution errors or unreachable network. Thus there should be a small sleep here */
             UA_sleep_ms(1000);

+ 25 - 17
examples/client_subscription_loop.c

@@ -14,52 +14,55 @@
 #include <signal.h>
 
 UA_Boolean running = true;
-UA_Logger logger = UA_Log_Stdout;
 
 static void stopHandler(int sign) {
-    UA_LOG_INFO(logger, UA_LOGCATEGORY_USERLAND, "Received Ctrl-C");
+    UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND, "Received Ctrl-C");
     running = 0;
 }
 
 static void
 handler_currentTimeChanged(UA_Client *client, UA_UInt32 subId, void *subContext,
                            UA_UInt32 monId, void *monContext, UA_DataValue *value) {
-    UA_LOG_INFO(logger, UA_LOGCATEGORY_USERLAND, "currentTime has changed!");
+    UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND, "currentTime has changed!");
     if(UA_Variant_hasScalarType(&value->value, &UA_TYPES[UA_TYPES_DATETIME])) {
         UA_DateTime raw_date = *(UA_DateTime *) value->value.data;
         UA_DateTimeStruct dts = UA_DateTime_toStruct(raw_date);
-        UA_LOG_INFO(logger, UA_LOGCATEGORY_USERLAND, "date is: %02u-%02u-%04u %02u:%02u:%02u.%03u",
-                        dts.day, dts.month, dts.year, dts.hour, dts.min, dts.sec, dts.milliSec);
+        UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,
+                    "date is: %02u-%02u-%04u %02u:%02u:%02u.%03u",
+                    dts.day, dts.month, dts.year, dts.hour, dts.min, dts.sec, dts.milliSec);
     }
 }
 
 static void
 deleteSubscriptionCallback(UA_Client *client, UA_UInt32 subscriptionId, void *subscriptionContext) {
-    UA_LOG_INFO(logger, UA_LOGCATEGORY_USERLAND, "Subscription Id %u was deleted", subscriptionId);
+    UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,
+                "Subscription Id %u was deleted", subscriptionId);
 }
 
 static void
 subscriptionInactivityCallback (UA_Client *client, UA_UInt32 subId, void *subContext) {
-    UA_LOG_INFO(logger, UA_LOGCATEGORY_USERLAND, "Inactivity for subscription %u", subId);
+    UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND, "Inactivity for subscription %u", subId);
 }
 
 static void
 stateCallback (UA_Client *client, UA_ClientState clientState) {
     switch(clientState) {
         case UA_CLIENTSTATE_DISCONNECTED:
-            UA_LOG_INFO(logger, UA_LOGCATEGORY_USERLAND, "The client is disconnected");
+            UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND, "The client is disconnected");
         break;
         case UA_CLIENTSTATE_WAITING_FOR_ACK:
-            UA_LOG_INFO(logger, UA_LOGCATEGORY_USERLAND, "Waiting for ack");
+            UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND, "Waiting for ack");
         break;
         case UA_CLIENTSTATE_CONNECTED:
-            UA_LOG_INFO(logger, UA_LOGCATEGORY_USERLAND, "A TCP connection to the server is open");
+            UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,
+                        "A TCP connection to the server is open");
         break;
         case UA_CLIENTSTATE_SECURECHANNEL:
-            UA_LOG_INFO(logger, UA_LOGCATEGORY_USERLAND, "A SecureChannel to the server is open");
+            UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,
+                        "A SecureChannel to the server is open");
         break;
         case UA_CLIENTSTATE_SESSION:{
-            UA_LOG_INFO(logger, UA_LOGCATEGORY_USERLAND, "A session with the server is open");
+            UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND, "A session with the server is open");
             /* A new session was created. We need to create the subscription. */
             /* Create a subscription */
             UA_CreateSubscriptionRequest request = UA_CreateSubscriptionRequest_default();
@@ -67,7 +70,8 @@ stateCallback (UA_Client *client, UA_ClientState clientState) {
                                                                                     NULL, NULL, deleteSubscriptionCallback);
 
             if(response.responseHeader.serviceResult == UA_STATUSCODE_GOOD)
-                UA_LOG_INFO(logger, UA_LOGCATEGORY_USERLAND, "Create subscription succeeded, id %u", response.subscriptionId);
+                UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,
+                            "Create subscription succeeded, id %u", response.subscriptionId);
             else
                 return;
 
@@ -80,15 +84,18 @@ stateCallback (UA_Client *client, UA_ClientState clientState) {
                                                           UA_TIMESTAMPSTORETURN_BOTH,
                                                           monRequest, NULL, handler_currentTimeChanged, NULL);
             if(monResponse.statusCode == UA_STATUSCODE_GOOD)
-                UA_LOG_INFO(logger, UA_LOGCATEGORY_USERLAND, "Monitoring UA_NS0ID_SERVER_SERVERSTATUS_CURRENTTIME', id %u", monResponse.monitoredItemId);
+                UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,
+                            "Monitoring UA_NS0ID_SERVER_SERVERSTATUS_CURRENTTIME', id %u",
+                            monResponse.monitoredItemId);
         }
         break;
         case UA_CLIENTSTATE_SESSION_RENEWED:
-            UA_LOG_INFO(logger, UA_LOGCATEGORY_USERLAND, "A session with the server is open (renewed)");
+            UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,
+                        "A session with the server is open (renewed)");
             /* The session was renewed. We don't need to recreate the subscription. */
         break;
         case UA_CLIENTSTATE_SESSION_DISCONNECTED:
-            UA_LOG_INFO(logger, UA_LOGCATEGORY_USERLAND, "Session disconnected");
+            UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND, "Session disconnected");
         break;
     }
     return;
@@ -112,7 +119,8 @@ main(void) {
         /* Alternatively you can also use UA_Client_getState to get the current state */
         UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
         if(retval != UA_STATUSCODE_GOOD) {
-            UA_LOG_ERROR(logger, UA_LOGCATEGORY_USERLAND, "Not connected. Retrying to connect in 1 second");
+            UA_LOG_ERROR(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,
+                         "Not connected. Retrying to connect in 1 second");
             /* The connect may timeout after 1 second (see above) or it may fail immediately on network errors */
             /* E.g. name resolution errors or unreachable network. Thus there should be a small sleep here */
             UA_sleep_ms(1000);

+ 3 - 5
examples/discovery/client_find_servers.c

@@ -7,8 +7,6 @@
 
 #include "open62541.h"
 
-UA_Logger logger = UA_Log_Stdout;
-
 #define DISCOVERY_SERVER_ENDPOINT "opc.tcp://localhost:4840"
 
 int main(void) {
@@ -25,7 +23,7 @@ int main(void) {
         UA_StatusCode retval = UA_Client_findServersOnNetwork(client, DISCOVERY_SERVER_ENDPOINT, 0, 0,
                                                               0, NULL, &serverOnNetworkSize, &serverOnNetwork);
         if(retval != UA_STATUSCODE_GOOD) {
-            UA_LOG_ERROR(logger, UA_LOGCATEGORY_SERVER,
+            UA_LOG_ERROR(UA_Log_Stdout, UA_LOGCATEGORY_SERVER,
                          "Could not call FindServersOnNetwork service. "
                          "Is the discovery server started? StatusCode %s",
                          UA_StatusCode_name(retval));
@@ -65,7 +63,7 @@ int main(void) {
         UA_Client_delete(client);
     }
     if(retval != UA_STATUSCODE_GOOD) {
-        UA_LOG_ERROR(logger, UA_LOGCATEGORY_SERVER, "Could not call FindServers service. "
+        UA_LOG_ERROR(UA_Log_Stdout, UA_LOGCATEGORY_SERVER, "Could not call FindServers service. "
                 "Is the discovery server started? StatusCode %s", UA_StatusCode_name(retval));
         return (int) retval;
     }
@@ -117,7 +115,7 @@ int main(void) {
     for(size_t i = 0; i < applicationDescriptionArraySize; i++) {
         UA_ApplicationDescription *description = &applicationDescriptionArray[i];
         if(description->discoveryUrlsSize == 0) {
-            UA_LOG_INFO(logger, UA_LOGCATEGORY_CLIENT,
+            UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_CLIENT,
                         "[GetEndpoints] Server %.*s did not provide any discovery urls. Skipping.",
                         (int)description->applicationUri.length, description->applicationUri.data);
             continue;

+ 25 - 23
examples/discovery/server_multicast.c

@@ -10,15 +10,13 @@
 #include "open62541.h"
 #include <signal.h>
 
-UA_Logger logger = UA_Log_Stdout;
 UA_Boolean running = true;
 
-
-const UA_ByteString
-    UA_SECURITY_POLICY_BASIC128_URI = {56, (UA_Byte *)"http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15"};
+const UA_ByteString UA_SECURITY_POLICY_BASIC128_URI =
+    {56, (UA_Byte *)"http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15"};
 
 static void stopHandler(int sign) {
-    UA_LOG_INFO(logger, UA_LOGCATEGORY_SERVER, "received ctrl-c");
+    UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_SERVER, "received ctrl-c");
     running = false;
 }
 
@@ -32,10 +30,10 @@ readInteger(UA_Server *server, const UA_NodeId *sessionId,
     UA_Variant_setScalarCopy(&value->value, myInteger, &UA_TYPES[UA_TYPES_INT32]);
 
     // we know the nodeid is a string
-    UA_LOG_INFO(logger, UA_LOGCATEGORY_USERLAND, "Node read %.*s",
+    UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND, "Node read %.*s",
                 (int)nodeId->identifier.string.length,
                 nodeId->identifier.string.data);
-    UA_LOG_INFO(logger, UA_LOGCATEGORY_USERLAND,
+    UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,
                 "read value %i", *(UA_UInt32 *)myInteger);
     return UA_STATUSCODE_GOOD;
 }
@@ -51,10 +49,10 @@ writeInteger(UA_Server *server, const UA_NodeId *sessionId,
         *myInteger = *(UA_Int32 *)value->value.data;
 
     // we know the nodeid is a string
-    UA_LOG_INFO(logger, UA_LOGCATEGORY_USERLAND, "Node written %.*s",
+    UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND, "Node written %.*s",
                 (int)nodeId->identifier.string.length,
                 nodeId->identifier.string.data);
-    UA_LOG_INFO(logger, UA_LOGCATEGORY_USERLAND,
+    UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,
                 "written value %i", *(UA_UInt32 *)myInteger);
     return UA_STATUSCODE_GOOD;
 }
@@ -66,7 +64,7 @@ serverOnNetworkCallback(const UA_ServerOnNetwork *serverOnNetwork, UA_Boolean is
                         UA_Boolean isTxtReceived, void *data) {
 
     if(discovery_url != NULL || !isServerAnnounce) {
-        UA_LOG_DEBUG(logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_DEBUG(UA_Log_Stdout, UA_LOGCATEGORY_SERVER,
                      "serverOnNetworkCallback called, but discovery URL "
                      "already initialized or is not announcing. Ignoring.");
         return; // we already have everything we need or we only want server announces
@@ -80,7 +78,7 @@ serverOnNetworkCallback(const UA_ServerOnNetwork *serverOnNetwork, UA_Boolean is
     // here you can filter for a specific LDS server, e.g. call FindServers on
     // the serverOnNetwork to make sure you are registering with the correct
     // LDS. We will ignore this for now
-    UA_LOG_INFO(logger, UA_LOGCATEGORY_SERVER, "Another server announced itself on %.*s",
+    UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_SERVER, "Another server announced itself on %.*s",
                 (int)serverOnNetwork->discoveryUrl.length, serverOnNetwork->discoveryUrl.data);
 
     if(discovery_url != NULL)
@@ -107,15 +105,16 @@ UA_EndpointDescription *getRegisterEndpointFromServer(const char *discoveryServe
     if (retval != UA_STATUSCODE_GOOD) {
         UA_Array_delete(endpointArray, endpointArraySize,
                         &UA_TYPES[UA_TYPES_ENDPOINTDESCRIPTION]);
-        UA_LOG_ERROR(logger, UA_LOGCATEGORY_SERVER, "GetEndpoints failed with %s", UA_StatusCode_name(retval));
+        UA_LOG_ERROR(UA_Log_Stdout, UA_LOGCATEGORY_SERVER,
+                     "GetEndpoints failed with %s", UA_StatusCode_name(retval));
         UA_Client_delete(client);
         return NULL;
     }
 
-    UA_LOG_DEBUG(logger, UA_LOGCATEGORY_SERVER, "Server has %zu endpoints", endpointArraySize);
+    UA_LOG_DEBUG(UA_Log_Stdout, UA_LOGCATEGORY_SERVER, "Server has %zu endpoints", endpointArraySize);
     UA_EndpointDescription *foundEndpoint = NULL;
     for (size_t i = 0; i < endpointArraySize; i++) {
-        UA_LOG_DEBUG(logger, UA_LOGCATEGORY_SERVER, "\tURL = %.*s, SecurityMode = %s",
+        UA_LOG_DEBUG(UA_Log_Stdout, UA_LOGCATEGORY_SERVER, "\tURL = %.*s, SecurityMode = %s",
                      (int) endpointArray[i].endpointUrl.length,
                      endpointArray[i].endpointUrl.data,
                      endpointArray[i].securityMode == UA_MESSAGESECURITYMODE_NONE ? "None" :
@@ -189,17 +188,19 @@ static UA_ByteString loadFile(const char *const path) {
 static
 UA_Client *getRegisterClient(UA_EndpointDescription *endpointRegister, int argc, char **argv) {
     if (endpointRegister->securityMode == UA_MESSAGESECURITYMODE_NONE) {
-        UA_LOG_INFO(logger, UA_LOGCATEGORY_SERVER, "Using LDS endpoint with security None");
+        UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_SERVER, "Using LDS endpoint with security None");
         return UA_Client_new(UA_ClientConfig_default);
     }
 #ifdef UA_ENABLE_ENCRYPTION
     if (endpointRegister->securityMode == UA_MESSAGESECURITYMODE_SIGN) {
-        UA_LOG_INFO(logger, UA_LOGCATEGORY_SERVER, "LDS endpoint which only supports Sign is currently not supported");
+        UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_SERVER,
+                    "LDS endpoint which only supports Sign is currently not supported");
         return NULL;
     }
 
     UA_Client *clientRegister;
-    UA_LOG_INFO(logger, UA_LOGCATEGORY_SERVER, "Using LDS endpoint with security SignAndEncrypt");
+    UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_SERVER,
+                "Using LDS endpoint with security SignAndEncrypt");
 
     UA_ByteString certificate = UA_BYTESTRING_NULL;
     UA_ByteString privateKey = UA_BYTESTRING_NULL;
@@ -295,7 +296,7 @@ int main(int argc, char **argv) {
     // Start the server and call iterate to wait for the multicast discovery of the LDS
     UA_StatusCode retval = UA_Server_run_startup(server);
     if(retval != UA_STATUSCODE_GOOD) {
-        UA_LOG_ERROR(logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_ERROR(UA_Log_Stdout, UA_LOGCATEGORY_SERVER,
                      "Could not start the server. StatusCode %s",
                      UA_StatusCode_name(retval));
         UA_Server_delete(server);
@@ -303,7 +304,7 @@ int main(int argc, char **argv) {
         UA_free(discovery_url);
         return 1;
     }
-    UA_LOG_INFO(logger, UA_LOGCATEGORY_SERVER,
+    UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_SERVER,
                 "Server started. Waiting for announce of LDS Server.");
     while (running && discovery_url == NULL)
         UA_Server_run_iterate(server, true);
@@ -313,14 +314,15 @@ int main(int argc, char **argv) {
         UA_free(discovery_url);
         return 1;
     }
-    UA_LOG_INFO(logger, UA_LOGCATEGORY_SERVER, "LDS-ME server found on %s", discovery_url);
+    UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_SERVER, "LDS-ME server found on %s", discovery_url);
 
     /* Check if the server supports sign and encrypt. OPC Foundation LDS requires an encrypted session for
      * RegisterServer call, our server currently uses encrpytion optionally */
     UA_EndpointDescription *endpointRegister = getRegisterEndpointFromServer(discovery_url);
     UA_free(discovery_url);
     if (endpointRegister == NULL || endpointRegister->securityMode == UA_MESSAGESECURITYMODE_INVALID) {
-        UA_LOG_ERROR(logger, UA_LOGCATEGORY_SERVER, "Could not find any suitable endpoints on discovery server");
+        UA_LOG_ERROR(UA_Log_Stdout, UA_LOGCATEGORY_SERVER,
+                     "Could not find any suitable endpoints on discovery server");
         UA_Server_delete(server);
         UA_ServerConfig_delete(config);
         return 1;
@@ -342,7 +344,7 @@ int main(int argc, char **argv) {
     retval = UA_Server_addPeriodicServerRegisterCallback(server, clientRegister, endpointUrl,
                                                          10 * 60 * 1000, 500, NULL);
     if(retval != UA_STATUSCODE_GOOD) {
-        UA_LOG_ERROR(logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_ERROR(UA_Log_Stdout, UA_LOGCATEGORY_SERVER,
                      "Could not create periodic job for server register. StatusCode %s",
                      UA_StatusCode_name(retval));
         UA_free(endpointUrl);
@@ -361,7 +363,7 @@ int main(int argc, char **argv) {
     // UNregister the server from the discovery server.
     retval = UA_Server_unregister_discovery(server, clientRegister);
     if (retval != UA_STATUSCODE_GOOD)
-        UA_LOG_ERROR(logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_ERROR(UA_Log_Stdout, UA_LOGCATEGORY_SERVER,
                      "Could not unregister server from discovery server. "
                      "StatusCode %s", UA_StatusCode_name(retval));
 

+ 8 - 9
examples/discovery/server_register.c

@@ -11,11 +11,10 @@
 
 #define DISCOVERY_SERVER_ENDPOINT "opc.tcp://localhost:4840"
 
-UA_Logger logger = UA_Log_Stdout;
 UA_Boolean running = true;
 
 static void stopHandler(int sign) {
-    UA_LOG_INFO(logger, UA_LOGCATEGORY_SERVER, "received ctrl-c");
+    UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_SERVER, "received ctrl-c");
     running = false;
 }
 
@@ -29,10 +28,10 @@ readInteger(UA_Server *server, const UA_NodeId *sessionId,
     UA_Variant_setScalarCopy(&value->value, myInteger, &UA_TYPES[UA_TYPES_INT32]);
 
     // we know the nodeid is a string
-    UA_LOG_INFO(logger, UA_LOGCATEGORY_USERLAND, "Node read %.*s",
+    UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND, "Node read %.*s",
                 (int)nodeId->identifier.string.length,
                 nodeId->identifier.string.data);
-    UA_LOG_INFO(logger, UA_LOGCATEGORY_USERLAND,
+    UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,
                 "read value %i", *(UA_UInt32 *)myInteger);
     return UA_STATUSCODE_GOOD;
 }
@@ -48,10 +47,10 @@ writeInteger(UA_Server *server, const UA_NodeId *sessionId,
         *myInteger = *(UA_Int32 *)value->value.data;
 
     // we know the nodeid is a string
-    UA_LOG_INFO(logger, UA_LOGCATEGORY_USERLAND, "Node written %.*s",
+    UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND, "Node written %.*s",
                 (int)nodeId->identifier.string.length,
                 nodeId->identifier.string.data);
-    UA_LOG_INFO(logger, UA_LOGCATEGORY_USERLAND,
+    UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,
                 "written value %i", *(UA_UInt32 *)myInteger);
     return UA_STATUSCODE_GOOD;
 }
@@ -98,7 +97,7 @@ int main(int argc, char **argv) {
     // UA_StatusCode retval = UA_Server_addPeriodicServerRegisterJob(server,
     // "opc.tcp://localhost:4840", 10*60*1000, 500, NULL);
     if(retval != UA_STATUSCODE_GOOD) {
-        UA_LOG_ERROR(logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_ERROR(UA_Log_Stdout, UA_LOGCATEGORY_SERVER,
                      "Could not create periodic job for server register. StatusCode %s",
                      UA_StatusCode_name(retval));
         UA_Client_disconnect(clientRegister);
@@ -110,7 +109,7 @@ int main(int argc, char **argv) {
 
     retval = UA_Server_run(server, &running);
     if(retval != UA_STATUSCODE_GOOD) {
-        UA_LOG_ERROR(logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_ERROR(UA_Log_Stdout, UA_LOGCATEGORY_SERVER,
                      "Could not start the server. StatusCode %s",
                      UA_StatusCode_name(retval));
         UA_Client_disconnect(clientRegister);
@@ -124,7 +123,7 @@ int main(int argc, char **argv) {
     retval = UA_Server_unregister_discovery(server, clientRegister);
     //retval = UA_Server_unregister_discovery(server, "opc.tcp://localhost:4840" );
     if(retval != UA_STATUSCODE_GOOD)
-        UA_LOG_ERROR(logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_ERROR(UA_Log_Stdout, UA_LOGCATEGORY_SERVER,
                      "Could not unregister server from discovery server. StatusCode %s",
                      UA_StatusCode_name(retval));
 

+ 2 - 1
examples/pubsub/tutorial_pubsub_connection.c

@@ -74,7 +74,8 @@ int main(void) {
     UA_NodeId connectionIdentifier;
     UA_StatusCode retval = UA_Server_addPubSubConnection(server, &connectionConfig, &connectionIdentifier);
     if(retval == UA_STATUSCODE_GOOD){
-        UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_SERVER, "The PubSub Connection was created successfully!");
+        UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_SERVER,
+                    "The PubSub Connection was created successfully!");
     }
 
     retval |= UA_Server_run(server, &running);

+ 1 - 2
examples/server.cpp

@@ -11,10 +11,9 @@
 using namespace std;
 
 UA_Boolean running = true;
-UA_Logger logger = UA_Log_Stdout;
 
 static void stopHandler(int sign) {
-    UA_LOG_INFO(logger, UA_LOGCATEGORY_SERVER, "received ctrl-c");
+    UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_SERVER, "received ctrl-c");
     running = false;
 }
 

+ 2 - 4
examples/server_certificate.c

@@ -10,10 +10,9 @@
 #include <signal.h>
 
 UA_Boolean running = true;
-UA_Logger logger = UA_Log_Stdout;
 
 static void stopHandler(int sign) {
-    UA_LOG_INFO(logger, UA_LOGCATEGORY_SERVER, "received ctrl-c");
+    UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_SERVER, "received ctrl-c");
     running = false;
 }
 
@@ -25,8 +24,7 @@ int main(int argc, char** argv) {
     /* load certificate */
     config->serverCertificate = loadFile("server_cert.der");
     if(config->serverCertificate.length > 0)
-        UA_LOG_INFO(logger, UA_LOGCATEGORY_SERVER, "Certificate loaded");
-
+        UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_SERVER, "Certificate loaded");
 
     UA_Server *server = UA_Server_new(config);
 

+ 0 - 2
examples/server_udp.c

@@ -5,8 +5,6 @@
 #include "open62541.h"
 #include <signal.h>
 
-UA_Logger logger = UA_Log_Stdout;
-
 UA_Boolean running = 1;
 static void stopHandler(int sign) {
     printf("Received Ctrl-C\n");

+ 33 - 20
include/ua_plugin_log.h

@@ -45,65 +45,78 @@ typedef enum {
     UA_LOGCATEGORY_SECURITYPOLICY
 } UA_LogCategory;
 
-/**
- * The message string and following varargs are formatted according to the rules
- * of the printf command. Do not call the logger directly. Instead, make use of
- * the convenience macros that take the minimum log-level defined in ua_config.h
- * into account. */
-
-typedef void (*UA_Logger)(UA_LogLevel level, UA_LogCategory category,
-                          const char *msg, va_list args);
+typedef struct {
+    /* The message string and following varargs are formatted according to the
+     * rules of the printf command. Use the convenience macros below that take
+     * the minimum log-level defined in ua_config.h into account. */
+    void (*log)(void *logContext, UA_LogLevel level, UA_LogCategory category,
+                const char *msg, va_list args);
+    void *logContext;
+    void (*clear)(void *logContext);
+} UA_Logger;
 
 static UA_INLINE UA_FORMAT(3,4) void
-UA_LOG_TRACE(UA_Logger logger, UA_LogCategory category, const char *msg, ...) {
+UA_LOG_TRACE(const UA_Logger *logger, UA_LogCategory category, const char *msg, ...) {
 #if UA_LOGLEVEL <= 100
+    if(!logger || !logger->log)
+        return;
     va_list args; va_start(args, msg);
-    logger(UA_LOGLEVEL_TRACE, category, msg, args);
+    logger->log(logger->logContext, UA_LOGLEVEL_TRACE, category, msg, args);
     va_end(args);
 #endif
 }
 
 static UA_INLINE UA_FORMAT(3,4) void
-UA_LOG_DEBUG(UA_Logger logger, UA_LogCategory category, const char *msg, ...) {
+UA_LOG_DEBUG(const UA_Logger *logger, UA_LogCategory category, const char *msg, ...) {
 #if UA_LOGLEVEL <= 200
+    if(!logger || !logger->log)
+        return;
     va_list args; va_start(args, msg);
-    logger(UA_LOGLEVEL_DEBUG, category, msg, args);
+    logger->log(logger->logContext, UA_LOGLEVEL_DEBUG, category, msg, args);
     va_end(args);
 #endif
 }
 
 static UA_INLINE UA_FORMAT(3,4) void
-UA_LOG_INFO(UA_Logger logger, UA_LogCategory category, const char *msg, ...) {
+UA_LOG_INFO(const UA_Logger *logger, UA_LogCategory category, const char *msg, ...) {
 #if UA_LOGLEVEL <= 300
+    if(!logger || !logger->log)
+        return;
     va_list args; va_start(args, msg);
-    logger(UA_LOGLEVEL_INFO, category, msg, args);
+    logger->log(logger->logContext, UA_LOGLEVEL_INFO, category, msg, args);
     va_end(args);
 #endif
 }
 
 static UA_INLINE UA_FORMAT(3,4) void
-UA_LOG_WARNING(UA_Logger logger, UA_LogCategory category, const char *msg, ...) {
+UA_LOG_WARNING(const UA_Logger *logger, UA_LogCategory category, const char *msg, ...) {
 #if UA_LOGLEVEL <= 400
+    if(!logger || !logger->log)
+        return;
     va_list args; va_start(args, msg);
-    logger(UA_LOGLEVEL_WARNING, category, msg, args);
+    logger->log(logger->logContext, UA_LOGLEVEL_WARNING, category, msg, args);
     va_end(args);
 #endif
 }
 
 static UA_INLINE UA_FORMAT(3,4) void
-UA_LOG_ERROR(UA_Logger logger, UA_LogCategory category, const char *msg, ...) {
+UA_LOG_ERROR(const UA_Logger *logger, UA_LogCategory category, const char *msg, ...) {
 #if UA_LOGLEVEL <= 500
+    if(!logger || !logger->log)
+        return;
     va_list args; va_start(args, msg);
-    logger(UA_LOGLEVEL_ERROR, category, msg, args);
+    logger->log(logger->logContext, UA_LOGLEVEL_ERROR, category, msg, args);
     va_end(args);
 #endif
 }
 
 static UA_INLINE UA_FORMAT(3,4) void
-UA_LOG_FATAL(UA_Logger logger, UA_LogCategory category, const char *msg, ...) {
+UA_LOG_FATAL(const UA_Logger *logger, UA_LogCategory category, const char *msg, ...) {
 #if UA_LOGLEVEL <= 600
+    if(!logger || !logger->log)
+        return;
     va_list args; va_start(args, msg);
-    logger(UA_LOGLEVEL_FATAL, category, msg, args);
+    logger->log(logger->logContext, UA_LOGLEVEL_FATAL, category, msg, args);
     va_end(args);
 #endif
 }

+ 1 - 1
include/ua_plugin_network.h

@@ -199,7 +199,7 @@ struct UA_ServerNetworkLayer {
  * @param logger the logger to use */
 typedef UA_Connection
 (*UA_ConnectClientConnection)(UA_ConnectionConfig config, const char *endpointUrl,
-                              const UA_UInt32 timeout, UA_Logger logger);
+                              const UA_UInt32 timeout, const UA_Logger *logger);
 
 _UA_END_DECLS
 

+ 7 - 6
include/ua_plugin_securitypolicy.h

@@ -354,7 +354,7 @@ struct UA_SecurityPolicy {
     UA_SecurityPolicyChannelModule channelModule;
     UA_CertificateVerification *certificateVerification;
 
-    UA_Logger logger;
+    const UA_Logger *logger;
 
     /*Updates the ApplicationInstanceCertificate and the corresponding
     * private key at runtime. */
@@ -387,11 +387,12 @@ UA_SecurityPolicy_getRemoteAsymEncryptionBufferLengthOverhead(const UA_SecurityP
                                                               size_t maxEncryptionLength);
 
 
-typedef UA_StatusCode (*UA_SecurityPolicy_Func)(UA_SecurityPolicy *policy,
-                                                UA_CertificateVerification *certificateVerification,
-                                                const UA_ByteString localCertificate,
-                                                const UA_ByteString localPrivateKey,
-                                                UA_Logger logger);
+typedef UA_StatusCode
+(*UA_SecurityPolicy_Func)(UA_SecurityPolicy *policy,
+                          UA_CertificateVerification *certificateVerification,
+                          const UA_ByteString localCertificate,
+                          const UA_ByteString localPrivateKey,
+                          const UA_Logger *logger);
 
 _UA_END_DECLS
 

+ 8 - 8
plugins/ua_config_default.c

@@ -66,7 +66,7 @@ createSecurityPolicyNoneEndpoint(UA_ServerConfig *conf, UA_Endpoint *endpoint,
                                  const UA_ByteString localCertificate) {
     UA_EndpointDescription_init(&endpoint->endpointDescription);
 
-    UA_SecurityPolicy_None(&endpoint->securityPolicy, NULL, localCertificate, conf->logger);
+    UA_SecurityPolicy_None(&endpoint->securityPolicy, NULL, localCertificate, &conf->logger);
     endpoint->endpointDescription.securityMode = UA_MESSAGESECURITYMODE_NONE;
     endpoint->endpointDescription.securityPolicyUri =
         UA_STRING_ALLOC("http://opcfoundation.org/UA/SecurityPolicy#None");
@@ -110,7 +110,7 @@ createSecurityPolicyBasic128Rsa15Endpoint(UA_ServerConfig *const conf,
 
     UA_StatusCode retval =
         UA_SecurityPolicy_Basic128Rsa15(&endpoint->securityPolicy, &conf->certificateVerification,
-                                        localCertificate, localPrivateKey, conf->logger);
+                                        localCertificate, localPrivateKey, &conf->logger);
     if(retval != UA_STATUSCODE_GOOD) {
         endpoint->securityPolicy.deleteMembers(&endpoint->securityPolicy);
         return retval;
@@ -148,8 +148,9 @@ createSecurityPolicyBasic256Sha256Endpoint(UA_ServerConfig *const conf,
     UA_EndpointDescription_init(&endpoint->endpointDescription);
 
     UA_StatusCode retval =
-        UA_SecurityPolicy_Basic256Sha256(&endpoint->securityPolicy, &conf->certificateVerification, localCertificate,
-                                         localPrivateKey, conf->logger);
+        UA_SecurityPolicy_Basic256Sha256(&endpoint->securityPolicy,
+                                         &conf->certificateVerification, localCertificate,
+                                         localPrivateKey, &conf->logger);
     if(retval != UA_STATUSCODE_GOOD) {
         endpoint->securityPolicy.deleteMembers(&endpoint->securityPolicy);
         return retval;
@@ -196,7 +197,7 @@ createDefaultConfig(void) {
 
     /* --> Start setting the default static config <-- */
     conf->nThreads = 1;
-    conf->logger = UA_Log_Stdout;
+    conf->logger = UA_Log_Stdout_;
 
     /* Server Description */
     conf->buildInfo.productUri = UA_STRING_ALLOC(PRODUCT_URI);
@@ -324,7 +325,7 @@ addDefaultNetworkLayers(UA_ServerConfig *conf, UA_UInt16 portNumber, UA_UInt32 s
         config.recvBufferSize = recvBufferSize;
 
     conf->networkLayers[0] =
-        UA_ServerNetworkLayerTCP(config, portNumber, conf->logger);
+        UA_ServerNetworkLayerTCP(config, portNumber, &conf->logger);
     if (!conf->networkLayers[0].handle)
         return UA_STATUSCODE_BADOUTOFMEMORY;
     conf->networkLayersSize = 1;
@@ -700,11 +701,10 @@ static UA_INLINE void UA_ClientConnectionTCP_poll_callback(UA_Client *client, vo
     UA_ClientConnectionTCP_poll(client, data);
 }
 
-
 const UA_ClientConfig UA_ClientConfig_default = {
     5000, /* .timeout, 5 seconds */
     10 * 60 * 1000, /* .secureChannelLifeTime, 10 minutes */
-    UA_Log_Stdout, /* .logger */
+    {UA_Log_Stdout_log, NULL, UA_Log_Stdout_clear}, /* .logger */
     { /* .localConnectionConfig */
         0, /* .protocolVersion */
         65535, /* .sendBufferSize, 64k per chunk */

+ 17 - 9
plugins/ua_log_stdout.c

@@ -1,7 +1,7 @@
 /* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
  * See http://creativecommons.org/publicdomain/zero/1.0/ for more information.
  *
- *    Copyright 2016-2017 (c) Fraunhofer IOSB (Author: Julius Pfrommer)
+ *    Copyright 2016-2018 (c) Fraunhofer IOSB (Author: Julius Pfrommer)
  *    Copyright 2017 (c) Thomas Stalder, Blue Time Concept SA
  */
 
@@ -31,11 +31,6 @@
 # define ANSI_COLOR_RESET   ""
 #endif
 
-#ifdef UA_ENABLE_MULTITHREADING
-#include <pthread.h>
-static pthread_mutex_t printf_mutex = PTHREAD_MUTEX_INITIALIZER;
-#endif
-
 const char *logLevelNames[6] = {"trace", "debug",
                                 ANSI_COLOR_GREEN "info",
                                 ANSI_COLOR_YELLOW "warn",
@@ -44,12 +39,17 @@ const char *logLevelNames[6] = {"trace", "debug",
 const char *logCategoryNames[7] = {"network", "channel", "session", "server",
                                    "client", "userland", "securitypolicy"};
 
+#ifdef UA_ENABLE_MULTITHREADING
+#include <pthread.h>
+static pthread_mutex_t printf_mutex = PTHREAD_MUTEX_INITIALIZER;
+#endif
+
 #ifdef __clang__
-__attribute__((__format__(__printf__, 3 , 0)))
+__attribute__((__format__(__printf__, 4 , 0)))
 #endif
 void
-UA_Log_Stdout(UA_LogLevel level, UA_LogCategory category,
-              const char *msg, va_list args) {
+UA_Log_Stdout_log(void *_, UA_LogLevel level, UA_LogCategory category,
+                  const char *msg, va_list args) {
     UA_Int64 tOffset = UA_DateTime_localTimeUtcOffset();
     UA_DateTimeStruct dts = UA_DateTime_toStruct(UA_DateTime_now() + tOffset);
 
@@ -68,3 +68,11 @@ UA_Log_Stdout(UA_LogLevel level, UA_LogCategory category,
     pthread_mutex_unlock(&printf_mutex);
 #endif
 }
+
+void
+UA_Log_Stdout_clear(void *logContext) {
+
+}
+
+const UA_Logger UA_Log_Stdout_ = {UA_Log_Stdout_log, NULL, UA_Log_Stdout_clear};
+const UA_Logger *UA_Log_Stdout = &UA_Log_Stdout_;

+ 11 - 4
plugins/ua_log_stdout.h

@@ -1,7 +1,7 @@
 /* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
  * See http://creativecommons.org/publicdomain/zero/1.0/ for more information. 
  *
- *    Copyright 2016 (c) Fraunhofer IOSB (Author: Julius Pfrommer)
+ *    Copyright 2016, 2018 (c) Fraunhofer IOSB (Author: Julius Pfrommer)
  */
 
 #ifndef UA_LOG_STDOUT_H_
@@ -11,9 +11,16 @@
 
 _UA_BEGIN_DECLS
 
-void UA_EXPORT
-UA_Log_Stdout(UA_LogLevel level, UA_LogCategory category,
-              const char *msg, va_list args);
+extern UA_EXPORT const UA_Logger UA_Log_Stdout_; /* Logger structure */
+extern UA_EXPORT const UA_Logger *UA_Log_Stdout; /* Shorthand pointer */
+
+/* Don't use these definitions. They are only exported as long as the client
+ * config is static and required compile-time  */
+UA_EXPORT void
+UA_Log_Stdout_log(void *_, UA_LogLevel level, UA_LogCategory category,
+                  const char *msg, va_list args);
+UA_EXPORT void
+UA_Log_Stdout_clear(void *logContext);
 
 _UA_END_DECLS
 

+ 3 - 3
plugins/ua_securitypolicies.h

@@ -16,7 +16,7 @@ _UA_BEGIN_DECLS
 UA_EXPORT UA_StatusCode
 UA_SecurityPolicy_None(UA_SecurityPolicy *policy,
                        UA_CertificateVerification *certificateVerification,
-                       const UA_ByteString localCertificate, UA_Logger logger);
+                       const UA_ByteString localCertificate, const UA_Logger *logger);
 
 #ifdef UA_ENABLE_ENCRYPTION
 
@@ -25,14 +25,14 @@ UA_SecurityPolicy_Basic128Rsa15(UA_SecurityPolicy *policy,
                                 UA_CertificateVerification *certificateVerification,
                                 const UA_ByteString localCertificate,
                                 const UA_ByteString localPrivateKey,
-                                UA_Logger logger);
+                                const UA_Logger *logger);
 
 UA_EXPORT UA_StatusCode
 UA_SecurityPolicy_Basic256Sha256(UA_SecurityPolicy *policy,
                                  UA_CertificateVerification *certificateVerification,
                                  const UA_ByteString localCertificate,
                                  const UA_ByteString localPrivateKey,
-                                 UA_Logger logger);
+                                 const UA_Logger *logger);
 
 #endif
 

+ 4 - 3
plugins/ua_securitypolicy_basic128rsa15.c

@@ -884,9 +884,10 @@ error:
 }
 
 UA_StatusCode
-UA_SecurityPolicy_Basic128Rsa15(UA_SecurityPolicy *policy, UA_CertificateVerification *certificateVerification,
-                                const UA_ByteString localCertificate, const UA_ByteString localPrivateKey,
-                                UA_Logger logger) {
+UA_SecurityPolicy_Basic128Rsa15(UA_SecurityPolicy *policy,
+                                UA_CertificateVerification *certificateVerification,
+                                const UA_ByteString localCertificate,
+                                const UA_ByteString localPrivateKey, const UA_Logger *logger) {
     memset(policy, 0, sizeof(UA_SecurityPolicy));
     policy->logger = logger;
 

+ 4 - 3
plugins/ua_securitypolicy_basic256sha256.c

@@ -908,9 +908,10 @@ error:
 }
 
 UA_StatusCode
-UA_SecurityPolicy_Basic256Sha256(UA_SecurityPolicy *policy, UA_CertificateVerification *certificateVerification,
-                                 const UA_ByteString localCertificate, const UA_ByteString localPrivateKey,
-                                 UA_Logger logger) {
+UA_SecurityPolicy_Basic256Sha256(UA_SecurityPolicy *policy,
+                                 UA_CertificateVerification *certificateVerification,
+                                 const UA_ByteString localCertificate,
+                                 const UA_ByteString localPrivateKey, const UA_Logger *logger) {
     memset(policy, 0, sizeof(UA_SecurityPolicy));
     policy->logger = logger;
 

+ 3 - 2
plugins/ua_securitypolicy_none.c

@@ -126,8 +126,9 @@ policy_deletemembers_none(UA_SecurityPolicy *policy) {
 }
 
 UA_StatusCode
-UA_SecurityPolicy_None(UA_SecurityPolicy *policy, UA_CertificateVerification *certificateVerification,
-                       const UA_ByteString localCertificate, UA_Logger logger) {
+UA_SecurityPolicy_None(UA_SecurityPolicy *policy,
+                       UA_CertificateVerification *certificateVerification,
+                       const UA_ByteString localCertificate, const UA_Logger *logger) {
     policy->policyContext = (void *)(uintptr_t)logger;
     policy->policyUri = UA_STRING("http://opcfoundation.org/UA/SecurityPolicy#None");
     policy->logger = logger;

+ 16 - 15
src/client/ua_client.c

@@ -35,9 +35,10 @@ static void
 UA_Client_init(UA_Client* client, UA_ClientConfig config) {
     memset(client, 0, sizeof(UA_Client));
     /* TODO: Select policy according to the endpoint */
-    UA_SecurityPolicy_None(&client->securityPolicy, NULL, UA_BYTESTRING_NULL, config.logger);
-    UA_SecureChannel_init(&client->channel);
     client->config = config;
+    UA_SecurityPolicy_None(&client->securityPolicy, NULL, UA_BYTESTRING_NULL,
+                           &client->config.logger);
+    UA_SecureChannel_init(&client->channel);
     if(client->config.stateCallback)
         client->config.stateCallback(client, client->state);
     /* Catch error during async connection */
@@ -103,7 +104,7 @@ UA_Client_secure_init(UA_Client* client, UA_ClientConfig config,
     /* Initiate client security policy */
     retval = (*securityPolicyFunction)(&client->securityPolicy,
                                        client->securityPolicy.certificateVerification,
-                                       certificate, privateKey, config.logger);
+                                       certificate, privateKey, &config.logger);
     if(retval != UA_STATUSCODE_GOOD) {
         UA_LOG_ERROR(client->channel.securityPolicy->logger, UA_LOGCATEGORY_CLIENT,
                      "Failed to setup the SecurityPolicy with error %s", UA_StatusCode_name(retval));
@@ -269,7 +270,7 @@ sendSymmetricServiceRequest(UA_Client *client, const void *request,
 
     /* Send the request */
     UA_UInt32 rqId = ++client->requestId;
-    UA_LOG_DEBUG(client->config.logger, UA_LOGCATEGORY_CLIENT,
+    UA_LOG_DEBUG(&client->config.logger, UA_LOGCATEGORY_CLIENT,
                  "Sending a request of type %i", requestType->typeId.identifier.numeric);
 
     if (client->channel.nextSecurityToken.tokenId != 0) // Change to the new security token if the secure channel has been renewed.
@@ -312,12 +313,12 @@ processAsyncResponse(UA_Client *client, UA_UInt32 requestId, const UA_NodeId *re
         UA_init(response, ac->responseType);
         if(UA_NodeId_equal(responseTypeId, &serviceFaultId)) {
             /* Decode as a ServiceFault, i.e. only the response header */
-            UA_LOG_INFO(client->config.logger, UA_LOGCATEGORY_CLIENT,
-                         "Received a ServiceFault response");
+            UA_LOG_INFO(&client->config.logger, UA_LOGCATEGORY_CLIENT,
+                        "Received a ServiceFault response");
             responseType = &UA_TYPES[UA_TYPES_SERVICEFAULT];
         } else {
             /* Close the connection */
-            UA_LOG_ERROR(client->config.logger, UA_LOGCATEGORY_CLIENT,
+            UA_LOG_ERROR(&client->config.logger, UA_LOGCATEGORY_CLIENT,
                          "Reply contains the wrong service response");
             retval = UA_STATUSCODE_BADCOMMUNICATIONERROR;
             goto process;
@@ -329,7 +330,7 @@ processAsyncResponse(UA_Client *client, UA_UInt32 requestId, const UA_NodeId *re
 
  process:
     if(retval != UA_STATUSCODE_GOOD) {
-        UA_LOG_INFO(client->config.logger, UA_LOGCATEGORY_CLIENT,
+        UA_LOG_INFO(&client->config.logger, UA_LOGCATEGORY_CLIENT,
                     "Could not decode the response with id %u due to %s",
                     requestId, UA_StatusCode_name(retval));
         ((UA_ResponseHeader*)response)->serviceResult = retval;
@@ -358,7 +359,7 @@ processServiceResponse(void *application, UA_SecureChannel *channel,
     /* Must be OPN or MSG */
     if(messageType != UA_MESSAGETYPE_OPN &&
        messageType != UA_MESSAGETYPE_MSG) {
-        UA_LOG_TRACE_CHANNEL(rd->client->config.logger, channel,
+        UA_LOG_TRACE_CHANNEL(&rd->client->config.logger, channel,
                              "Invalid message type");
         return;
     }
@@ -387,14 +388,14 @@ processServiceResponse(void *application, UA_SecureChannel *channel,
     expectedNodeId = UA_NODEID_NUMERIC(0, rd->responseType->binaryEncodingId);
     if(!UA_NodeId_equal(&responseId, &expectedNodeId)) {
         if(UA_NodeId_equal(&responseId, &serviceFaultId)) {
-            UA_LOG_INFO(rd->client->config.logger, UA_LOGCATEGORY_CLIENT,
+            UA_LOG_INFO(&rd->client->config.logger, UA_LOGCATEGORY_CLIENT,
                          "Received a ServiceFault response");
             UA_init(rd->response, rd->responseType);
             retval = UA_decodeBinary(message, &offset, rd->response,
                                      &UA_TYPES[UA_TYPES_SERVICEFAULT], NULL);
         } else {
             /* Close the connection */
-            UA_LOG_ERROR(rd->client->config.logger, UA_LOGCATEGORY_CLIENT,
+            UA_LOG_ERROR(&rd->client->config.logger, UA_LOGCATEGORY_CLIENT,
                          "Reply contains the wrong service response");
             retval = UA_STATUSCODE_BADCOMMUNICATIONERROR;
         }
@@ -402,10 +403,10 @@ processServiceResponse(void *application, UA_SecureChannel *channel,
     }
 
 #ifdef UA_ENABLE_TYPENAMES
-    UA_LOG_DEBUG(rd->client->config.logger, UA_LOGCATEGORY_CLIENT,
+    UA_LOG_DEBUG(&rd->client->config.logger, UA_LOGCATEGORY_CLIENT,
                  "Decode a message of type %s", rd->responseType->typeName);
 #else
-    UA_LOG_DEBUG(rd->client->config.logger, UA_LOGCATEGORY_CLIENT,
+    UA_LOG_DEBUG(&rd->client->config.logger, UA_LOGCATEGORY_CLIENT,
                  "Decode a message of type %u", responseId.identifier.numeric);
 #endif
 
@@ -418,7 +419,7 @@ finish:
     if(retval != UA_STATUSCODE_GOOD) {
         if(retval == UA_STATUSCODE_BADENCODINGLIMITSEXCEEDED)
             retval = UA_STATUSCODE_BADRESPONSETOOLARGE;
-        UA_LOG_INFO(rd->client->config.logger, UA_LOGCATEGORY_CLIENT,
+        UA_LOG_INFO(&rd->client->config.logger, UA_LOGCATEGORY_CLIENT,
                     "Error receiving the response with status code %s",
                     UA_StatusCode_name(retval));
 
@@ -622,7 +623,7 @@ UA_Client_sendAsyncRequest(UA_Client *client, const void *request,
                            const UA_DataType *responseType, void *userdata,
                            UA_UInt32 *requestId) {
     if (UA_Client_getState(client) < UA_CLIENTSTATE_SECURECHANNEL) {
-        UA_LOG_INFO(client->config.logger, UA_LOGCATEGORY_CLIENT,
+        UA_LOG_INFO(&client->config.logger, UA_LOGCATEGORY_CLIENT,
                     "Cient must be connected to send high-level requests");
         return UA_STATUSCODE_GOOD;
     }

+ 18 - 18
src/client/ua_client_connect.c

@@ -51,7 +51,7 @@ processACKResponse(void *application, UA_Connection *connection, UA_ByteString *
     UA_TcpAcknowledgeMessage ackMessage;
     retval = UA_TcpMessageHeader_decodeBinary(chunk, &offset, &messageHeader);
     if(retval != UA_STATUSCODE_GOOD) {
-        UA_LOG_INFO(client->config.logger, UA_LOGCATEGORY_NETWORK,
+        UA_LOG_INFO(&client->config.logger, UA_LOGCATEGORY_NETWORK,
                     "Decoding ACK message failed");
         return retval;
     }
@@ -66,7 +66,7 @@ processACKResponse(void *application, UA_Connection *connection, UA_ByteString *
         UA_StatusCode error = *(UA_StatusCode*)(&chunk->data[offset]);
         UA_UInt32 len = *((UA_UInt32*)&chunk->data[offset + 4]);
         UA_Byte *data = (UA_Byte*)&chunk->data[offset + 4+4];
-        UA_LOG_ERROR(client->config.logger, UA_LOGCATEGORY_NETWORK,
+        UA_LOG_ERROR(&client->config.logger, UA_LOGCATEGORY_NETWORK,
                     "Received ERR response. %s - %.*s", UA_StatusCode_name(error), len, data);
         return error;
     }
@@ -77,11 +77,11 @@ processACKResponse(void *application, UA_Connection *connection, UA_ByteString *
     /* Decode the ACK message */
     retval = UA_TcpAcknowledgeMessage_decodeBinary(chunk, &offset, &ackMessage);
     if(retval != UA_STATUSCODE_GOOD) {
-        UA_LOG_INFO(client->config.logger, UA_LOGCATEGORY_NETWORK,
+        UA_LOG_INFO(&client->config.logger, UA_LOGCATEGORY_NETWORK,
                     "Decoding ACK message failed");
         return retval;
     }
-    UA_LOG_DEBUG(client->config.logger, UA_LOGCATEGORY_NETWORK, "Received ACK message");
+    UA_LOG_DEBUG(&client->config.logger, UA_LOGCATEGORY_NETWORK, "Received ACK message");
 
     /* Process the ACK message */
     return UA_Connection_processHELACK(connection, &client->config.localConnectionConfig,
@@ -127,18 +127,18 @@ HelAckHandshake(UA_Client *client) {
     message.length = messageHeader.messageSize;
     retval = conn->send(conn, &message);
     if(retval != UA_STATUSCODE_GOOD) {
-        UA_LOG_INFO(client->config.logger, UA_LOGCATEGORY_NETWORK,
+        UA_LOG_INFO(&client->config.logger, UA_LOGCATEGORY_NETWORK,
                     "Sending HEL failed");
         return retval;
     }
-    UA_LOG_DEBUG(client->config.logger, UA_LOGCATEGORY_NETWORK,
+    UA_LOG_DEBUG(&client->config.logger, UA_LOGCATEGORY_NETWORK,
                  "Sent HEL message");
 
     /* Loop until we have a complete chunk */
     retval = UA_Connection_receiveChunksBlocking(conn, client, processACKResponse,
                                                  client->config.timeout);
     if(retval != UA_STATUSCODE_GOOD) {
-        UA_LOG_INFO(client->config.logger, UA_LOGCATEGORY_NETWORK,
+        UA_LOG_INFO(&client->config.logger, UA_LOGCATEGORY_NETWORK,
                     "Receiving ACK message failed with %s", UA_StatusCode_name(retval));
         if(retval == UA_STATUSCODE_BADCONNECTIONCLOSED)
             client->state = UA_CLIENTSTATE_DISCONNECTED;
@@ -161,10 +161,10 @@ processDecodedOPNResponse(UA_Client *client, UA_OpenSecureChannelResponse *respo
     UA_ByteString_init(&response->serverNonce);
 
     if(client->channel.state == UA_SECURECHANNELSTATE_OPEN)
-        UA_LOG_DEBUG(client->config.logger, UA_LOGCATEGORY_SECURECHANNEL,
+        UA_LOG_DEBUG(&client->config.logger, UA_LOGCATEGORY_SECURECHANNEL,
                      "SecureChannel in the server renewed");
     else
-        UA_LOG_DEBUG(client->config.logger, UA_LOGCATEGORY_SECURECHANNEL,
+        UA_LOG_DEBUG(&client->config.logger, UA_LOGCATEGORY_SECURECHANNEL,
                      "Opened SecureChannel acknowledged by the server");
 
     /* Response.securityToken.revisedLifetime is UInt32 we need to cast it to
@@ -192,11 +192,11 @@ openSecureChannel(UA_Client *client, UA_Boolean renew) {
     opnSecRq.requestHeader.authenticationToken = client->authenticationToken;
     if(renew) {
         opnSecRq.requestType = UA_SECURITYTOKENREQUESTTYPE_RENEW;
-        UA_LOG_DEBUG(client->config.logger, UA_LOGCATEGORY_SECURECHANNEL,
+        UA_LOG_DEBUG(&client->config.logger, UA_LOGCATEGORY_SECURECHANNEL,
                      "Requesting to renew the SecureChannel");
     } else {
         opnSecRq.requestType = UA_SECURITYTOKENREQUESTTYPE_ISSUE;
-        UA_LOG_DEBUG(client->config.logger, UA_LOGCATEGORY_SECURECHANNEL,
+        UA_LOG_DEBUG(&client->config.logger, UA_LOGCATEGORY_SECURECHANNEL,
                      "Requesting to open a SecureChannel");
     }
 
@@ -212,13 +212,13 @@ openSecureChannel(UA_Client *client, UA_Boolean renew) {
         UA_SecureChannel_sendAsymmetricOPNMessage(&client->channel, requestId, &opnSecRq,
                                                   &UA_TYPES[UA_TYPES_OPENSECURECHANNELREQUEST]);
     if(retval != UA_STATUSCODE_GOOD) {
-        UA_LOG_ERROR(client->config.logger, UA_LOGCATEGORY_SECURECHANNEL,
+        UA_LOG_ERROR(&client->config.logger, UA_LOGCATEGORY_SECURECHANNEL,
                      "Sending OPN message failed with error %s", UA_StatusCode_name(retval));
         UA_Client_disconnect(client);
         return retval;
     }
 
-    UA_LOG_DEBUG(client->config.logger, UA_LOGCATEGORY_SECURECHANNEL, "OPN message sent");
+    UA_LOG_DEBUG(&client->config.logger, UA_LOGCATEGORY_SECURECHANNEL, "OPN message sent");
 
     /* Increase nextChannelRenewal to avoid that we re-start renewal when
      * publish responses are received before the OPN response arrives. */
@@ -376,7 +376,7 @@ activateSession(UA_Client *client) {
                         &response, &UA_TYPES[UA_TYPES_ACTIVATESESSIONRESPONSE]);
 
     if(response.responseHeader.serviceResult != UA_STATUSCODE_GOOD) {
-        UA_LOG_ERROR(client->config.logger, UA_LOGCATEGORY_CLIENT,
+        UA_LOG_ERROR(&client->config.logger, UA_LOGCATEGORY_CLIENT,
                      "ActivateSession failed with error code %s",
                      UA_StatusCode_name(response.responseHeader.serviceResult));
     }
@@ -404,7 +404,7 @@ UA_Client_getEndpointsInternal(UA_Client *client, size_t* endpointDescriptionsSi
 
     if(response.responseHeader.serviceResult != UA_STATUSCODE_GOOD) {
         UA_StatusCode retval = response.responseHeader.serviceResult;
-        UA_LOG_ERROR(client->config.logger, UA_LOGCATEGORY_CLIENT,
+        UA_LOG_ERROR(&client->config.logger, UA_LOGCATEGORY_CLIENT,
                      "GetEndpointRequest failed with error code %s",
                      UA_StatusCode_name(retval));
         UA_GetEndpointsResponse_deleteMembers(&response);
@@ -475,11 +475,11 @@ getEndpoints(UA_Client *client) {
                     &UA_TYPES[UA_TYPES_ENDPOINTDESCRIPTION]);
 
     if(!endpointFound) {
-        UA_LOG_ERROR(client->config.logger, UA_LOGCATEGORY_CLIENT,
+        UA_LOG_ERROR(&client->config.logger, UA_LOGCATEGORY_CLIENT,
                      "No suitable endpoint found");
         retval = UA_STATUSCODE_BADINTERNALERROR;
     } else if(!tokenFound) {
-        UA_LOG_ERROR(client->config.logger, UA_LOGCATEGORY_CLIENT,
+        UA_LOG_ERROR(&client->config.logger, UA_LOGCATEGORY_CLIENT,
                      "No suitable UserTokenPolicy found for the possible endpoints");
         retval = UA_STATUSCODE_BADINTERNALERROR;
     }
@@ -564,7 +564,7 @@ UA_Client_connectInternal(UA_Client *client, const char *endpointUrl,
     client->connection =
         client->config.connectionFunc(client->config.localConnectionConfig,
                                       endpointUrl, client->config.timeout,
-                                      client->config.logger);
+                                      &client->config.logger);
     if(client->connection.state != UA_CONNECTION_OPENING) {
         retval = UA_STATUSCODE_BADCONNECTIONCLOSED;
         goto cleanup;

+ 28 - 31
src/client/ua_client_connect_async.c

@@ -63,11 +63,11 @@ processACKResponseAsync(void *application, UA_Connection *connection,
     client->connectStatus |= UA_TcpAcknowledgeMessage_decodeBinary(
             chunk, &offset, &ackMessage);
     if (client->connectStatus != UA_STATUSCODE_GOOD) {
-        UA_LOG_INFO(client->config.logger, UA_LOGCATEGORY_NETWORK,
+        UA_LOG_INFO(&client->config.logger, UA_LOGCATEGORY_NETWORK,
                      "Decoding ACK message failed");
         return client->connectStatus;
     }
-    UA_LOG_DEBUG(client->config.logger, UA_LOGCATEGORY_NETWORK, "Received ACK message");
+    UA_LOG_DEBUG(&client->config.logger, UA_LOGCATEGORY_NETWORK, "Received ACK message");
 
     client->connectStatus =
         UA_Connection_processHELACK(connection, &client->config.localConnectionConfig,
@@ -125,11 +125,11 @@ sendHELMessage(UA_Client *client) {
     client->connectStatus = conn->send (conn, &message);
 
     if (client->connectStatus != UA_STATUSCODE_GOOD) {
-        UA_LOG_INFO(client->config.logger, UA_LOGCATEGORY_NETWORK,
+        UA_LOG_INFO(&client->config.logger, UA_LOGCATEGORY_NETWORK,
                     "Sending HEL failed");
         return client->connectStatus;
     }
-    UA_LOG_DEBUG(client->config.logger, UA_LOGCATEGORY_NETWORK,
+    UA_LOG_DEBUG(&client->config.logger, UA_LOGCATEGORY_NETWORK,
                  "Sent HEL message");
     setClientState(client, UA_CLIENTSTATE_WAITING_FOR_ACK);
     return client->connectStatus;
@@ -188,9 +188,9 @@ processDecodedOPNResponseAsync(void *application, UA_SecureChannel *channel,
     client->channel.remoteNonce = response.serverNonce;
     UA_ResponseHeader_deleteMembers(&response.responseHeader); /* the other members were moved */
     if(client->channel.state == UA_SECURECHANNELSTATE_OPEN)
-        UA_LOG_DEBUG(client->config.logger, UA_LOGCATEGORY_SECURECHANNEL, "SecureChannel renewed");
+        UA_LOG_DEBUG(&client->config.logger, UA_LOGCATEGORY_SECURECHANNEL, "SecureChannel renewed");
     else
-        UA_LOG_DEBUG(client->config.logger, UA_LOGCATEGORY_SECURECHANNEL, "SecureChannel opened");
+        UA_LOG_DEBUG(&client->config.logger, UA_LOGCATEGORY_SECURECHANNEL, "SecureChannel opened");
     client->channel.state = UA_SECURECHANNELSTATE_OPEN;
 
     if(client->state < UA_CLIENTSTATE_SECURECHANNEL)
@@ -256,11 +256,11 @@ openSecureChannelAsync(UA_Client *client/*, UA_Boolean renew*/) {
     opnSecRq.requestHeader.authenticationToken = client->authenticationToken;
     /*if(renew) {
         opnSecRq.requestType = UA_SECURITYTOKENREQUESTTYPE_RENEW;
-        UA_LOG_DEBUG(client->config.logger, UA_LOGCATEGORY_SECURECHANNEL,
+        UA_LOG_DEBUG(&client->config.logger, UA_LOGCATEGORY_SECURECHANNEL,
                      "Requesting to renew the SecureChannel");
     } else {*/
         opnSecRq.requestType = UA_SECURITYTOKENREQUESTTYPE_ISSUE;
-        UA_LOG_DEBUG(client->config.logger, UA_LOGCATEGORY_SECURECHANNEL,
+        UA_LOG_DEBUG(&client->config.logger, UA_LOGCATEGORY_SECURECHANNEL,
                      "Requesting to open a SecureChannel");
     //}
     opnSecRq.securityMode = client->channel.securityMode;
@@ -290,7 +290,7 @@ openSecureChannelAsync(UA_Client *client/*, UA_Boolean renew*/) {
 
     if(retval != UA_STATUSCODE_GOOD) {
         client->connectStatus = retval;
-        UA_LOG_ERROR(client->config.logger, UA_LOGCATEGORY_SECURECHANNEL,
+        UA_LOG_ERROR(&client->config.logger, UA_LOGCATEGORY_SECURECHANNEL,
                       "Sending OPN message failed with error %s",
                       UA_StatusCode_name(retval));
         UA_Client_disconnect(client);
@@ -299,8 +299,8 @@ openSecureChannelAsync(UA_Client *client/*, UA_Boolean renew*/) {
         return retval;
     }
 
-    UA_LOG_DEBUG (client->config.logger, UA_LOGCATEGORY_SECURECHANNEL,
-                  "OPN message sent");
+    UA_LOG_DEBUG(&client->config.logger, UA_LOGCATEGORY_SECURECHANNEL,
+                 "OPN message sent");
 
     /* Store the entry for async processing and return */
     /*if(renew) {
@@ -316,11 +316,9 @@ responseActivateSession(UA_Client *client, void *userdata, UA_UInt32 requestId,
     UA_ActivateSessionResponse *activateResponse =
             (UA_ActivateSessionResponse *) response;
     if(activateResponse->responseHeader.serviceResult) {
-        UA_LOG_ERROR(
-                client->config.logger,
-                UA_LOGCATEGORY_CLIENT,
-                "ActivateSession failed with error code %s",
-                UA_StatusCode_name(activateResponse->responseHeader.serviceResult));
+        UA_LOG_ERROR(&client->config.logger, UA_LOGCATEGORY_CLIENT,
+                     "ActivateSession failed with error code %s",
+                     UA_StatusCode_name(activateResponse->responseHeader.serviceResult));
     }
     client->connection.state = UA_CONNECTION_ESTABLISHED;
     setClientState(client, UA_CLIENTSTATE_SESSION);
@@ -393,9 +391,9 @@ responseGetEndpoints(UA_Client *client, void *userdata, UA_UInt32 requestId,
 
     if (resp->responseHeader.serviceResult != UA_STATUSCODE_GOOD) {
         client->connectStatus = resp->responseHeader.serviceResult;
-        UA_LOG_ERROR (client->config.logger, UA_LOGCATEGORY_CLIENT,
-                      "GetEndpointRequest failed with error code %s",
-                      UA_StatusCode_name (client->connectStatus));
+        UA_LOG_ERROR(&client->config.logger, UA_LOGCATEGORY_CLIENT,
+                     "GetEndpointRequest failed with error code %s",
+                     UA_StatusCode_name (client->connectStatus));
         UA_GetEndpointsResponse_deleteMembers(resp);
         return;
     }
@@ -455,13 +453,12 @@ responseGetEndpoints(UA_Client *client, void *userdata, UA_UInt32 requestId,
                     &UA_TYPES[UA_TYPES_ENDPOINTDESCRIPTION]);
 
     if(!endpointFound) {
-        UA_LOG_ERROR(client->config.logger, UA_LOGCATEGORY_CLIENT,
-                      "No suitable endpoint found");
+        UA_LOG_ERROR(&client->config.logger, UA_LOGCATEGORY_CLIENT,
+                     "No suitable endpoint found");
         client->connectStatus = UA_STATUSCODE_BADINTERNALERROR;
     } else if(!tokenFound) {
-        UA_LOG_ERROR(
-                client->config.logger, UA_LOGCATEGORY_CLIENT,
-                "No suitable UserTokenPolicy found for the possible endpoints");
+        UA_LOG_ERROR(&client->config.logger, UA_LOGCATEGORY_CLIENT,
+                     "No suitable UserTokenPolicy found for the possible endpoints");
         client->connectStatus = UA_STATUSCODE_BADINTERNALERROR;
     }
     requestSession(client, &requestId);
@@ -536,7 +533,7 @@ requestSession(UA_Client *client, UA_UInt32 *requestId) {
 
 UA_StatusCode
 UA_Client_connect_iterate(UA_Client *client) {
-    UA_LOG_TRACE(client->config.logger, UA_LOGCATEGORY_CLIENT,
+    UA_LOG_TRACE(&client->config.logger, UA_LOGCATEGORY_CLIENT,
                  "Client connect iterate");
     if (client->connection.state == UA_CONNECTION_ESTABLISHED){
         if (client->state < UA_CLIENTSTATE_WAITING_FOR_ACK)
@@ -546,7 +543,7 @@ UA_Client_connect_iterate(UA_Client *client) {
     /* If server is not connected */
     if (client->connection.state == UA_CONNECTION_CLOSED) {
         client->connectStatus = UA_STATUSCODE_BADCONNECTIONCLOSED;
-        UA_LOG_ERROR(client->config.logger, UA_LOGCATEGORY_NETWORK,
+        UA_LOG_ERROR(&client->config.logger, UA_LOGCATEGORY_NETWORK,
                      "No connection to server.");
     }
 
@@ -557,7 +554,7 @@ UA_StatusCode
 UA_Client_connect_async(UA_Client *client, const char *endpointUrl,
                         UA_ClientAsyncServiceCallback callback,
                         void *userdata) {
-    UA_LOG_TRACE(client->config.logger, UA_LOGCATEGORY_CLIENT,
+    UA_LOG_TRACE(&client->config.logger, UA_LOGCATEGORY_CLIENT,
                  "Client internal async");
 
     if(client->state >= UA_CLIENTSTATE_WAITING_FOR_ACK)
@@ -572,9 +569,9 @@ UA_Client_connect_async(UA_Client *client, const char *endpointUrl,
     UA_StatusCode retval = UA_STATUSCODE_GOOD;
     client->connection = client->config.initConnectionFunc(
             client->config.localConnectionConfig, endpointUrl,
-            client->config.timeout, client->config.logger);
+            client->config.timeout, &client->config.logger);
     if(client->connection.state != UA_CONNECTION_OPENING) {
-        UA_LOG_TRACE(client->config.logger, UA_LOGCATEGORY_CLIENT,
+        UA_LOG_TRACE(&client->config.logger, UA_LOGCATEGORY_CLIENT,
                      "Could not init async connection");
         retval = UA_STATUSCODE_BADCONNECTIONCLOSED;
         goto cleanup;
@@ -605,7 +602,7 @@ UA_Client_connect_async(UA_Client *client, const char *endpointUrl,
     client->asyncConnectCall.userdata = userdata;
 
     if(!client->connection.connectCallbackID) {
-        UA_LOG_TRACE(client->config.logger, UA_LOGCATEGORY_CLIENT,
+        UA_LOG_TRACE(&client->config.logger, UA_LOGCATEGORY_CLIENT,
                      "Adding async connection callback");
         retval = UA_Client_addRepeatedCallback(
                      client, client->config.pollConnectionFunc, &client->connection, 100.0,
@@ -635,7 +632,7 @@ UA_Client_connect_async(UA_Client *client, const char *endpointUrl,
     return retval;
 
  cleanup:
-    UA_LOG_TRACE(client->config.logger, UA_LOGCATEGORY_CLIENT,
+    UA_LOG_TRACE(&client->config.logger, UA_LOGCATEGORY_CLIENT,
                  "Failure during async connect");
     UA_Client_disconnect(client);
     return retval;

+ 22 - 20
src/client/ua_client_subscriptions.c

@@ -138,7 +138,8 @@ UA_Client_Subscriptions_delete(UA_Client *client, const UA_DeleteSubscriptionsRe
 
     /* Loop over the removed subscriptions and remove internally */
     for(size_t i = 0; i < request.subscriptionIdsSize; i++) {
-        if(response.results[i] != UA_STATUSCODE_GOOD && response.results[i] != UA_STATUSCODE_BADSUBSCRIPTIONIDINVALID) {
+        if(response.results[i] != UA_STATUSCODE_GOOD &&
+           response.results[i] != UA_STATUSCODE_BADSUBSCRIPTIONIDINVALID) {
             /* Something was wrong, reinsert the subscription in the list */
             if (subs[i])
                 LIST_INSERT_HEAD(&client->subscriptions, subs[i], listEntry);
@@ -146,7 +147,7 @@ UA_Client_Subscriptions_delete(UA_Client *client, const UA_DeleteSubscriptionsRe
         }
 
         if(!subs[i]) {
-            UA_LOG_INFO(client->config.logger, UA_LOGCATEGORY_CLIENT,
+            UA_LOG_INFO(&client->config.logger, UA_LOGCATEGORY_CLIENT,
                         "No internal representation of subscription %u",
                         request.subscriptionIds[i]);
             continue;
@@ -279,7 +280,7 @@ __UA_Client_MonitoredItems_create(UA_Client *client,
             (request->itemsToCreate[i].itemToMonitor.attributeId == UA_ATTRIBUTEID_EVENTNOTIFIER);
         LIST_INSERT_HEAD(&sub->monitoredItems, newMon, listEntry);
 
-        UA_LOG_DEBUG(client->config.logger, UA_LOGCATEGORY_CLIENT,
+        UA_LOG_DEBUG(&client->config.logger, UA_LOGCATEGORY_CLIENT,
                     "Subscription %u | Added a MonitoredItem with handle %u",
                      sub->subscriptionId, newMon->clientHandle);
     }
@@ -381,7 +382,7 @@ UA_Client_MonitoredItems_delete(UA_Client *client, const UA_DeleteMonitoredItems
 
     UA_Client_Subscription *sub = findSubscription(client, request.subscriptionId);
     if(!sub) {
-        UA_LOG_INFO(client->config.logger, UA_LOGCATEGORY_CLIENT,
+        UA_LOG_INFO(&client->config.logger, UA_LOGCATEGORY_CLIENT,
                     "No internal representation of subscription %u",
                     request.subscriptionId);
         return response;
@@ -493,14 +494,14 @@ processDataChangeNotification(UA_Client *client, UA_Client_Subscription *sub,
         }
 
         if(!mon) {
-            UA_LOG_DEBUG(client->config.logger, UA_LOGCATEGORY_CLIENT,
+            UA_LOG_DEBUG(&client->config.logger, UA_LOGCATEGORY_CLIENT,
                          "Could not process a notification with clienthandle %u on subscription %u",
                          min->clientHandle, sub->subscriptionId);
             continue;
         }
 
         if(mon->isEventMonitoredItem) {
-            UA_LOG_DEBUG(client->config.logger, UA_LOGCATEGORY_CLIENT,
+            UA_LOG_DEBUG(&client->config.logger, UA_LOGCATEGORY_CLIENT,
                          "MonitoredItem is configured for Events. But received a "
                          "DataChangeNotification.");
             continue;
@@ -526,14 +527,14 @@ processEventNotification(UA_Client *client, UA_Client_Subscription *sub,
         }
 
         if(!mon) {
-            UA_LOG_DEBUG(client->config.logger, UA_LOGCATEGORY_CLIENT,
+            UA_LOG_DEBUG(&client->config.logger, UA_LOGCATEGORY_CLIENT,
                          "Could not process a notification with clienthandle %u on subscription %u",
                          eventFieldList->clientHandle, sub->subscriptionId);
             continue;
         }
 
         if(!mon->isEventMonitoredItem) {
-            UA_LOG_DEBUG(client->config.logger, UA_LOGCATEGORY_CLIENT,
+            UA_LOG_DEBUG(&client->config.logger, UA_LOGCATEGORY_CLIENT,
                          "MonitoredItem is configured for DataChanges. But received a "
                          "EventNotification.");
             continue;
@@ -574,13 +575,13 @@ processNotificationMessage(UA_Client *client, UA_Client_Subscription *sub,
             sub->statusChangeCallback(client, sub->subscriptionId, sub->context,
                                       (UA_StatusChangeNotification*)msg->content.decoded.data);
         } else {
-            UA_LOG_WARNING(client->config.logger, UA_LOGCATEGORY_CLIENT,
+            UA_LOG_WARNING(&client->config.logger, UA_LOGCATEGORY_CLIENT,
                            "Dropped a StatusChangeNotification since no callback is registered");
         }
         return;
     }
 
-    UA_LOG_WARNING(client->config.logger, UA_LOGCATEGORY_CLIENT,
+    UA_LOG_WARNING(&client->config.logger, UA_LOGCATEGORY_CLIENT,
                    "Unknown notification message type");
 }
 
@@ -594,11 +595,11 @@ UA_Client_Subscriptions_processPublishResponse(UA_Client *client, UA_PublishRequ
     if(response->responseHeader.serviceResult == UA_STATUSCODE_BADTOOMANYPUBLISHREQUESTS) {
         if(client->config.outStandingPublishRequests > 1) {
             client->config.outStandingPublishRequests--;
-            UA_LOG_WARNING(client->config.logger, UA_LOGCATEGORY_CLIENT,
+            UA_LOG_WARNING(&client->config.logger, UA_LOGCATEGORY_CLIENT,
                           "Too many publishrequest, reduce outStandingPublishRequests to %d",
                            client->config.outStandingPublishRequests);
         } else {
-            UA_LOG_ERROR(client->config.logger, UA_LOGCATEGORY_CLIENT,
+            UA_LOG_ERROR(&client->config.logger, UA_LOGCATEGORY_CLIENT,
                          "Too many publishrequest when outStandingPublishRequests = 1");
             UA_Client_Subscriptions_deleteSingle(client, response->subscriptionId);
         }
@@ -615,7 +616,7 @@ UA_Client_Subscriptions_processPublishResponse(UA_Client *client, UA_PublishRequ
 
     if(response->responseHeader.serviceResult == UA_STATUSCODE_BADSESSIONCLOSED) {
         if(client->state >= UA_CLIENTSTATE_SESSION) {
-            UA_LOG_WARNING(client->config.logger, UA_LOGCATEGORY_CLIENT,
+            UA_LOG_WARNING(&client->config.logger, UA_LOGCATEGORY_CLIENT,
                            "Received Publish Response with code %s",
                             UA_StatusCode_name(response->responseHeader.serviceResult));
         }
@@ -624,13 +625,13 @@ UA_Client_Subscriptions_processPublishResponse(UA_Client *client, UA_PublishRequ
 
     if(response->responseHeader.serviceResult == UA_STATUSCODE_BADSESSIONIDINVALID) {
         UA_Client_disconnect(client); /* TODO: This should be handled before the process callback */
-        UA_LOG_WARNING(client->config.logger, UA_LOGCATEGORY_CLIENT,
+        UA_LOG_WARNING(&client->config.logger, UA_LOGCATEGORY_CLIENT,
                        "Received BadSessionIdInvalid");
         return;
     }
 
     if(response->responseHeader.serviceResult != UA_STATUSCODE_GOOD) {
-        UA_LOG_WARNING(client->config.logger, UA_LOGCATEGORY_CLIENT,
+        UA_LOG_WARNING(&client->config.logger, UA_LOGCATEGORY_CLIENT,
                        "Received Publish Response with code %s",
                        UA_StatusCode_name(response->responseHeader.serviceResult));
         return;
@@ -639,7 +640,7 @@ UA_Client_Subscriptions_processPublishResponse(UA_Client *client, UA_PublishRequ
     UA_Client_Subscription *sub = findSubscription(client, response->subscriptionId);
     if(!sub) {
         response->responseHeader.serviceResult = UA_STATUSCODE_BADINTERNALERROR;
-        UA_LOG_WARNING(client->config.logger, UA_LOGCATEGORY_CLIENT,
+        UA_LOG_WARNING(&client->config.logger, UA_LOGCATEGORY_CLIENT,
                        "Received Publish Response for a non-existant subscription");
         return;
     }
@@ -648,7 +649,7 @@ UA_Client_Subscriptions_processPublishResponse(UA_Client *client, UA_PublishRequ
 
     /* Detect missing message - OPC Unified Architecture, Part 4 5.13.1.1 e) */
     if(UA_Client_Subscriptions_nextSequenceNumber(sub->sequenceNumber) != msg->sequenceNumber) {
-        UA_LOG_WARNING(client->config.logger, UA_LOGCATEGORY_CLIENT,
+        UA_LOG_WARNING(&client->config.logger, UA_LOGCATEGORY_CLIENT,
                      "Invalid subscription sequence number: expected %u but got %u",
                      UA_Client_Subscriptions_nextSequenceNumber(sub->sequenceNumber),
                      msg->sequenceNumber);
@@ -676,7 +677,7 @@ UA_Client_Subscriptions_processPublishResponse(UA_Client *client, UA_PublishRequ
         UA_Client_NotificationsAckNumber *tmpAck = (UA_Client_NotificationsAckNumber*)
             UA_malloc(sizeof(UA_Client_NotificationsAckNumber));
         if(!tmpAck) {
-            UA_LOG_WARNING(client->config.logger, UA_LOGCATEGORY_CLIENT,
+            UA_LOG_WARNING(&client->config.logger, UA_LOGCATEGORY_CLIENT,
                            "Not enough memory to store the acknowledgement for a publish "
                            "message on subscription %u", sub->subscriptionId);
             break;
@@ -738,8 +739,9 @@ UA_Client_Subscriptions_backgroundPublishInactivityCheck(UA_Client *client) {
             sub->lastActivity = UA_DateTime_nowMonotonic();
 
             if(client->config.subscriptionInactivityCallback)
-                client->config.subscriptionInactivityCallback(client, sub->subscriptionId, sub->context);
-            UA_LOG_ERROR(client->config.logger, UA_LOGCATEGORY_CLIENT,
+                client->config.subscriptionInactivityCallback(client, sub->subscriptionId,
+                                                              sub->context);
+            UA_LOG_ERROR(&client->config.logger, UA_LOGCATEGORY_CLIENT,
                          "Inactivity for Subscription %u.", sub->subscriptionId);
         }
     }

+ 18 - 11
src/pubsub/ua_pubsub.c

@@ -479,7 +479,8 @@ UA_Server_updateWriterGroupConfig(UA_Server *server, UA_NodeId writerGroupIdenti
         currentWriterGroup->config.publishingInterval = config->publishingInterval;
         UA_WriterGroup_addPublishCallback(server, currentWriterGroup);
     } else if (currentWriterGroup->config.priority != config->priority) {
-        UA_LOG_WARNING(server->config.logger, UA_LOGCATEGORY_SERVER, "No or unsupported WriterGroup update.");
+        UA_LOG_WARNING(&server->config.logger, UA_LOGCATEGORY_SERVER,
+                       "No or unsupported WriterGroup update.");
     }
     return UA_STATUSCODE_GOOD;
 }
@@ -899,7 +900,7 @@ UA_DataSetWriter_generateDataSetMessage(UA_Server *server, UA_DataSetMessage *da
     if(dataSetWriterMessageDataType->networkMessageNumber != 0 ||
        dataSetWriterMessageDataType->dataSetOffset != 0 ||
        dataSetWriterMessageDataType->configuredSize !=0 ) {
-        UA_LOG_WARNING(server->config.logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_WARNING(&server->config.logger, UA_LOGCATEGORY_SERVER,
                        "Static DSM configuration not supported. Using defaults");
         dataSetWriterMessageDataType->networkMessageNumber = 0;
         dataSetWriterMessageDataType->dataSetOffset = 0;
@@ -998,20 +999,22 @@ UA_DataSetWriter_generateDataSetMessage(UA_Server *server, UA_DataSetMessage *da
  */
 void
 UA_WriterGroup_publishCallback(UA_Server *server, UA_WriterGroup *writerGroup) {
-    if(!writerGroup){
-        UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER, "Publish failed. WriterGroup not found");
+    if(!writerGroup) {
+        UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER,
+                     "Publish failed. WriterGroup not found");
         return;
     }
     if(writerGroup->writersCount <= 0)
         return;
 
     if(writerGroup->config.encodingMimeType != UA_PUBSUB_ENCODING_UADP) {
-        UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER, "Unknown encoding type.");
+        UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER, "Unknown encoding type.");
         return;
     }
     UA_PubSubConnection *connection = UA_PubSubConnection_findConnectionbyId(server, writerGroup->linkedConnection);
-    if(!connection){
-        UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER, "Publish failed. PubSubConnection invalid.");
+    if(!connection) {
+        UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER,
+                     "Publish failed. PubSubConnection invalid.");
         return;
     }
     //prevent error if the maxEncapsulatedDataSetMessageCount is set to 0->1
@@ -1021,7 +1024,8 @@ UA_WriterGroup_publishCallback(UA_Server *server, UA_WriterGroup *writerGroup) {
 
     UA_DataSetMessage *dsmStore = (UA_DataSetMessage *) UA_calloc(writerGroup->writersCount, sizeof(UA_DataSetMessage));
     if(!dsmStore) {
-        UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER, "DataSetMessage allocation failed");
+        UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER,
+                     "DataSetMessage allocation failed");
         return;
     }
     memset(dsmStore, 0, sizeof(UA_DataSetMessage) * writerGroup->writersCount);
@@ -1050,13 +1054,15 @@ UA_WriterGroup_publishCallback(UA_Server *server, UA_WriterGroup *writerGroup) {
         //if promoted fields are contained in the PublishedDataSet, then this DSM must encapsulated in one NM
         UA_PublishedDataSet *tmpPublishedDataSet = UA_PublishedDataSet_findPDSbyId(server, tmpDataSetWriter->connectedDataSet);
         if(!tmpPublishedDataSet) {
-            UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER, "Publish failed. PublishedDataSet not found");
+            UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER,
+                         "Publish failed. PublishedDataSet not found");
             return;
         }
         if(tmpPublishedDataSet->promotedFieldsCount > 0) {
             if(UA_DataSetWriter_generateDataSetMessage(server, &dsmStore[(writerGroup->writersCount - 1) - singleNetworkMessagesCount],
                                                        tmpDataSetWriter) != UA_STATUSCODE_GOOD){
-                UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER, "Publish failed. DataSetMessage creation failed");
+                UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER,
+                             "Publish failed. DataSetMessage creation failed");
                 return;
             };
             dsWriterIds[(writerGroup->writersCount - 1) - singleNetworkMessagesCount] = tmpDataSetWriter->config.dataSetWriterId;
@@ -1065,7 +1071,8 @@ UA_WriterGroup_publishCallback(UA_Server *server, UA_WriterGroup *writerGroup) {
             singleNetworkMessagesCount++;
         } else {
             if(UA_DataSetWriter_generateDataSetMessage(server, &dsmStore[combinedNetworkMessageCount], tmpDataSetWriter) != UA_STATUSCODE_GOOD){
-                UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER, "Publish failed. DataSetMessage creation failed");
+                UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER,
+                             "Publish failed. DataSetMessage creation failed");
                 return;
             };
             dsWriterIds[combinedNetworkMessageCount] = tmpDataSetWriter->config.dataSetWriterId;

+ 10 - 10
src/pubsub/ua_pubsub_manager.c

@@ -27,7 +27,7 @@ UA_Server_addPubSubConnection(UA_Server *server,
         }
     }
     if(!tl) {
-        UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER,
                      "PubSub Connection creation failed. Requested transport layer not found.");
         return UA_STATUSCODE_BADNOTFOUND;
     }
@@ -36,14 +36,14 @@ UA_Server_addPubSubConnection(UA_Server *server,
     UA_PubSubConnectionConfig *tmpConnectionConfig = (UA_PubSubConnectionConfig *)
         UA_calloc(1, sizeof(UA_PubSubConnectionConfig));
     if(!tmpConnectionConfig){
-        UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER,
                      "PubSub Connection creation failed. Out of Memory.");
         return UA_STATUSCODE_BADOUTOFMEMORY;
     }
 
     UA_StatusCode retval = UA_PubSubConnectionConfig_copy(connectionConfig, tmpConnectionConfig);
     if(retval != UA_STATUSCODE_GOOD){
-        UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER,
                      "PubSub Connection creation failed. Could not copy the config.");
         return retval;
     }
@@ -55,7 +55,7 @@ UA_Server_addPubSubConnection(UA_Server *server,
     if(!newConnectionsField) {
         UA_PubSubConnectionConfig_deleteMembers(tmpConnectionConfig);
         UA_free(tmpConnectionConfig);
-        UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER,
                      "PubSub Connection creation failed. Out of Memory.");
         return UA_STATUSCODE_BADOUTOFMEMORY;
     }
@@ -86,7 +86,7 @@ UA_Server_addPubSubConnection(UA_Server *server,
             UA_free(server->pubSubManager.connections);
             server->pubSubManager.connections = NULL;
         }
-        UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER,
                      "PubSub Connection creation failed. Transport layer creation problem.");
         return UA_STATUSCODE_BADINTERNALERROR;
     }
@@ -153,12 +153,12 @@ UA_Server_addPublishedDataSet(UA_Server *server, const UA_PublishedDataSetConfig
                               UA_NodeId *pdsIdentifier) {
     UA_AddPublishedDataSetResult result = {UA_STATUSCODE_BADINVALIDARGUMENT, 0, NULL, {0, 0}};
     if(!publishedDataSetConfig){
-        UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER,
                      "PublishedDataSet creation failed. No config passed in.");
         return result;
     }
     if(publishedDataSetConfig->publishedDataSetType != UA_PUBSUB_DATASET_PUBLISHEDITEMS){
-        UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER,
                      "PublishedDataSet creation failed. Unsupported PublishedDataSet type.");
         return result;
     }
@@ -166,7 +166,7 @@ UA_Server_addPublishedDataSet(UA_Server *server, const UA_PublishedDataSetConfig
     UA_PublishedDataSetConfig tmpPublishedDataSetConfig;
     memset(&tmpPublishedDataSetConfig, 0, sizeof(UA_PublishedDataSetConfig));
     if(UA_PublishedDataSetConfig_copy(publishedDataSetConfig, &tmpPublishedDataSetConfig) != UA_STATUSCODE_GOOD){
-        UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER,
                      "PublishedDataSet creation failed. Configuration copy failed.");
 		result.addResult = UA_STATUSCODE_BADINTERNALERROR;
         return result;
@@ -177,7 +177,7 @@ UA_Server_addPublishedDataSet(UA_Server *server, const UA_PublishedDataSetConfig
                        sizeof(UA_PublishedDataSet) * (server->pubSubManager.publishedDataSetsSize + 1));
     if(!newPubSubDataSetField) {
         UA_PublishedDataSetConfig_deleteMembers(&tmpPublishedDataSetConfig);
-        UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER,
                      "PublishedDataSet creation failed. Out of Memory.");
 		result.addResult = UA_STATUSCODE_BADOUTOFMEMORY;
 		return result;
@@ -291,7 +291,7 @@ UA_PubSubManager_generateUniqueNodeId(UA_Server *server, UA_NodeId *nodeId) {
  * action also delete the configured PubSub transport Layers. */
 void
 UA_PubSubManager_delete(UA_Server *server, UA_PubSubManager *pubSubManager) {
-    UA_LOG_INFO(server->config.logger, UA_LOGCATEGORY_SERVER, "PubSub cleanup was called.");
+    UA_LOG_INFO(&server->config.logger, UA_LOGCATEGORY_SERVER, "PubSub cleanup was called.");
     //free the currently configured transport layers
     UA_free(server->config.pubsubTransportLayers);
     server->config.pubsubTransportLayersSize = 0;

+ 13 - 8
src/pubsub/ua_pubsub_ns0.c

@@ -111,7 +111,8 @@ onRead(UA_Server *server, const UA_NodeId *sessionId, void *sessionContext,
                         UA_Variant_setScalar(&value, &pubSubConnection->config->publisherId.numeric, &UA_TYPES[UA_TYPES_UINT32]);
                     break;
                 default:
-                    UA_LOG_WARNING(server->config.logger, UA_LOGCATEGORY_SERVER, "Read error! Unknown property.");
+                    UA_LOG_WARNING(&server->config.logger, UA_LOGCATEGORY_SERVER,
+                                   "Read error! Unknown property.");
             }
             break;
         case UA_NS0ID_WRITERGROUPTYPE:
@@ -124,11 +125,13 @@ onRead(UA_Server *server, const UA_NodeId *sessionId, void *sessionContext,
                     UA_Variant_setScalar(&value, &writerGroup->config.publishingInterval, &UA_TYPES[UA_TYPES_DURATION]);
                     break;
                 default:
-                    UA_LOG_WARNING(server->config.logger, UA_LOGCATEGORY_SERVER, "Read error! Unknown property.");
+                    UA_LOG_WARNING(&server->config.logger, UA_LOGCATEGORY_SERVER,
+                                   "Read error! Unknown property.");
             }
             break;
         default:
-            UA_LOG_WARNING(server->config.logger, UA_LOGCATEGORY_SERVER, "Read error! Unknown parent element.");
+            UA_LOG_WARNING(&server->config.logger, UA_LOGCATEGORY_SERVER,
+                           "Read error! Unknown parent element.");
     }
     UA_Server_writeValue(server, *nodeid, value);
 }
@@ -160,11 +163,13 @@ onWrite(UA_Server *server, const UA_NodeId *sessionId, void *sessionContext,
                     UA_WriterGroupConfig_deleteMembers(&writerGroupConfig);
                     break;
                 default:
-                    UA_LOG_WARNING(server->config.logger, UA_LOGCATEGORY_SERVER, "Write error! Unknown property element.");
+                    UA_LOG_WARNING(&server->config.logger, UA_LOGCATEGORY_SERVER,
+                                   "Write error! Unknown property element.");
             }
             break;
         default:
-            UA_LOG_WARNING(server->config.logger, UA_LOGCATEGORY_SERVER, "Read error! Unknown parent element.");
+            UA_LOG_WARNING(&server->config.logger, UA_LOGCATEGORY_SERVER,
+                           "Read error! Unknown parent element.");
     }
 }
 
@@ -638,7 +643,7 @@ connectionTypeDestructor(UA_Server *server,
                          const UA_NodeId *sessionId, void *sessionContext,
                          const UA_NodeId *typeId, void *typeContext,
                          const UA_NodeId *nodeId, void **nodeContext) {
-    UA_LOG_INFO(server->config.logger, UA_LOGCATEGORY_USERLAND, "Connection destructor called!");
+    UA_LOG_INFO(&server->config.logger, UA_LOGCATEGORY_USERLAND, "Connection destructor called!");
     UA_NodeId publisherIdNode;
     publisherIdNode = findSingleChildNode(server, UA_QUALIFIEDNAME(0, "PublisherId"),
                                        UA_NODEID_NUMERIC(0, UA_NS0ID_HASPROPERTY), *nodeId);
@@ -655,7 +660,7 @@ writerGroupTypeDestructor(UA_Server *server,
                           const UA_NodeId *sessionId, void *sessionContext,
                           const UA_NodeId *typeId, void *typeContext,
                           const UA_NodeId *nodeId, void **nodeContext) {
-    UA_LOG_INFO(server->config.logger, UA_LOGCATEGORY_USERLAND, "WriterGroup destructor called!");
+    UA_LOG_INFO(&server->config.logger, UA_LOGCATEGORY_USERLAND, "WriterGroup destructor called!");
     UA_NodeId intervalNode;
     intervalNode = findSingleChildNode(server, UA_QUALIFIEDNAME(0, "PublishingInterval"),
                                        UA_NODEID_NUMERIC(0, UA_NS0ID_HASPROPERTY), *nodeId);
@@ -671,7 +676,7 @@ dataSetWriterTypeDestructor(UA_Server *server,
                             const UA_NodeId *sessionId, void *sessionContext,
                             const UA_NodeId *typeId, void *typeContext,
                             const UA_NodeId *nodeId, void **nodeContext) {
-    UA_LOG_INFO(server->config.logger, UA_LOGCATEGORY_USERLAND, "DataSetWriter destructor called!");
+    UA_LOG_INFO(&server->config.logger, UA_LOGCATEGORY_USERLAND, "DataSetWriter destructor called!");
 }
 
 UA_StatusCode

+ 1 - 1
src/server/ua_discovery_manager.c

@@ -61,7 +61,7 @@ initMulticastDiscoveryServer(UA_DiscoveryManager *dm, UA_Server* server) {
 
     if((server->discoveryManager.mdnsSocket = discovery_createMulticastSocket()) == UA_INVALID_SOCKET) {
         UA_LOG_SOCKET_ERRNO_WRAP(
-                UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER,
+                UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER,
                      "Could not create multicast socket. Error: %s", errno_str));
         return UA_STATUSCODE_BADUNEXPECTEDERROR;
     }

+ 5 - 5
src/server/ua_securechannel_manager.c

@@ -80,7 +80,7 @@ UA_SecureChannelManager_cleanupTimedOut(UA_SecureChannelManager *cm,
             entry->channel.securityToken.createdAt +
             (UA_DateTime)(entry->channel.securityToken.revisedLifetime * UA_DATETIME_MSEC);
         if(timeout < nowMonotonic) {
-            UA_LOG_INFO_CHANNEL(cm->server->config.logger, &entry->channel,
+            UA_LOG_INFO_CHANNEL(&cm->server->config.logger, &entry->channel,
                                 "SecureChannel has timed out");
             removeSecureChannel(cm, entry);
             continue;
@@ -99,7 +99,7 @@ purgeFirstChannelWithoutSession(UA_SecureChannelManager *cm) {
     channel_entry *entry;
     TAILQ_FOREACH(entry, &cm->channels, pointers) {
         if(LIST_EMPTY(&entry->channel.sessions)) {
-            UA_LOG_INFO_CHANNEL(cm->server->config.logger, &entry->channel,
+            UA_LOG_INFO_CHANNEL(&cm->server->config.logger, &entry->channel,
                                 "Channel was purged since maxSecureChannels was "
                                 "reached and channel had no session attached");
             removeSecureChannel(cm, entry);
@@ -124,7 +124,7 @@ UA_SecureChannelManager_create(UA_SecureChannelManager *const cm, UA_Connection
        !purgeFirstChannelWithoutSession(cm))
         return UA_STATUSCODE_BADOUTOFMEMORY;
 
-    UA_LOG_INFO(cm->server->config.logger, UA_LOGCATEGORY_SECURECHANNEL,
+    UA_LOG_INFO(&cm->server->config.logger, UA_LOGCATEGORY_SECURECHANNEL,
                 "Creating a new SecureChannel");
 
     channel_entry *entry = (channel_entry *)UA_malloc(sizeof(channel_entry));
@@ -159,7 +159,7 @@ UA_SecureChannelManager_open(UA_SecureChannelManager *cm, UA_SecureChannel *chan
                              const UA_OpenSecureChannelRequest *request,
                              UA_OpenSecureChannelResponse *response) {
     if(channel->state != UA_SECURECHANNELSTATE_FRESH) {
-        UA_LOG_ERROR_CHANNEL(cm->server->config.logger, channel,
+        UA_LOG_ERROR_CHANNEL(&cm->server->config.logger, channel,
                              "Called open on already open or closed channel");
         return UA_STATUSCODE_BADINTERNALERROR;
     }
@@ -217,7 +217,7 @@ UA_SecureChannelManager_renew(UA_SecureChannelManager *cm, UA_SecureChannel *cha
                               const UA_OpenSecureChannelRequest *request,
                               UA_OpenSecureChannelResponse *response) {
     if(channel->state != UA_SECURECHANNELSTATE_OPEN) {
-        UA_LOG_ERROR_CHANNEL(cm->server->config.logger, channel,
+        UA_LOG_ERROR_CHANNEL(&cm->server->config.logger, channel,
                              "Called renew on channel which is not open");
         return UA_STATUSCODE_BADINTERNALERROR;
     }

+ 4 - 5
src/server/ua_server.c

@@ -1,4 +1,3 @@
-
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. 
@@ -243,7 +242,7 @@ UA_Server_new(const UA_ServerConfig *config) {
     /* Initialize namespace 0*/
     UA_StatusCode retVal = UA_Server_initNS0(server);
     if(retVal != UA_STATUSCODE_GOOD) {
-        UA_LOG_ERROR(config->logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_ERROR(&config->logger, UA_LOGCATEGORY_SERVER,
                      "Namespace 0 could not be bootstrapped with error %s. "
                      "Shutting down the server.",
                      UA_StatusCode_name(retVal));
@@ -354,7 +353,7 @@ UA_Server_run_startup(UA_Server *server) {
 	
 	/* At least one endpoint has to be configured */
     if(server->config.endpointsSize == 0) {
-        UA_LOG_WARNING(server->config.logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_WARNING(&server->config.logger, UA_LOGCATEGORY_SERVER,
                        "There has to be at least one endpoint.");
     }
 
@@ -374,7 +373,7 @@ UA_Server_run_startup(UA_Server *server) {
 
     /* Spin up the worker threads */
 #ifdef UA_ENABLE_MULTITHREADING
-    UA_LOG_INFO(server->config.logger, UA_LOGCATEGORY_SERVER,
+    UA_LOG_INFO(&server->config.logger, UA_LOGCATEGORY_SERVER,
                 "Spinning up %u worker thread(s)", server->config.nThreads);
     UA_WorkQueue_start(&server->workQueue, server->config.nThreads);
 #endif
@@ -458,7 +457,7 @@ UA_Server_run_shutdown(UA_Server *server) {
 
 #ifdef UA_ENABLE_MULTITHREADING
     /* Shut down the workers */
-    UA_LOG_INFO(server->config.logger, UA_LOGCATEGORY_SERVER,
+    UA_LOG_INFO(&server->config.logger, UA_LOGCATEGORY_SERVER,
                 "Shutting down %u worker thread(s)",
                 (UA_UInt32)server->workQueue.workersSize);
     UA_WorkQueue_stop(&server->workQueue);

+ 24 - 23
src/server/ua_server_binary.c

@@ -294,7 +294,7 @@ processHEL(UA_Server *server, UA_Connection *connection,
     remoteConfig.maxChunkCount = helloMessage.maxChunkCount;
     retval = UA_Connection_processHELACK(connection, localConfig, &remoteConfig);
     if(retval != UA_STATUSCODE_GOOD) {
-        UA_LOG_INFO(server->config.logger, UA_LOGCATEGORY_NETWORK,
+        UA_LOG_INFO(&server->config.logger, UA_LOGCATEGORY_NETWORK,
                     "Connection %i | Error during the HEL/ACK handshake",
                     (int)(connection->sockfd));
         return retval;
@@ -345,7 +345,8 @@ processOPN(UA_Server *server, UA_SecureChannel *channel,
 
     if(retval != UA_STATUSCODE_GOOD) {
         UA_NodeId_deleteMembers(&requestType);
-        UA_LOG_INFO_CHANNEL(server->config.logger, channel, "Could not decode the NodeId. Closing the connection");
+        UA_LOG_INFO_CHANNEL(&server->config.logger, channel,
+                            "Could not decode the NodeId. Closing the connection");
         UA_SecureChannelManager_close(&server->secureChannelManager, channel->securityToken.channelId);
         return retval;
     }
@@ -356,7 +357,7 @@ processOPN(UA_Server *server, UA_SecureChannel *channel,
        requestType.identifier.numeric != UA_TYPES[UA_TYPES_OPENSECURECHANNELREQUEST].binaryEncodingId) {
         UA_NodeId_deleteMembers(&requestType);
         UA_OpenSecureChannelRequest_deleteMembers(&openSecureChannelRequest);
-        UA_LOG_INFO_CHANNEL(server->config.logger, channel,
+        UA_LOG_INFO_CHANNEL(&server->config.logger, channel,
                             "Could not decode the OPN message. Closing the connection.");
         UA_SecureChannelManager_close(&server->secureChannelManager, channel->securityToken.channelId);
         return retval;
@@ -369,7 +370,7 @@ processOPN(UA_Server *server, UA_SecureChannel *channel,
     Service_OpenSecureChannel(server, channel, &openSecureChannelRequest, &openScResponse);
     UA_OpenSecureChannelRequest_deleteMembers(&openSecureChannelRequest);
     if(openScResponse.responseHeader.serviceResult != UA_STATUSCODE_GOOD) {
-        UA_LOG_INFO_CHANNEL(server->config.logger, channel, "Could not open a SecureChannel. "
+        UA_LOG_INFO_CHANNEL(&server->config.logger, channel, "Could not open a SecureChannel. "
                             "Closing the connection.");
         UA_SecureChannelManager_close(&server->secureChannelManager,
                                       channel->securityToken.channelId);
@@ -381,7 +382,7 @@ processOPN(UA_Server *server, UA_SecureChannel *channel,
                                                        &UA_TYPES[UA_TYPES_OPENSECURECHANNELRESPONSE]);
     UA_OpenSecureChannelResponse_deleteMembers(&openScResponse);
     if(retval != UA_STATUSCODE_GOOD) {
-        UA_LOG_INFO_CHANNEL(server->config.logger, channel,
+        UA_LOG_INFO_CHANNEL(&server->config.logger, channel,
                             "Could not send the OPN answer with error code %s",
                             UA_StatusCode_name(retval));
         UA_SecureChannelManager_close(&server->secureChannelManager,
@@ -421,11 +422,11 @@ processMSG(UA_Server *server, UA_SecureChannel *channel,
                        &responseType, &service, &serviceInsitu, &sessionRequired, &serviceType);
     if(!requestType) {
         if(requestTypeId.identifier.numeric == 787) {
-            UA_LOG_INFO_CHANNEL(server->config.logger, channel,
+            UA_LOG_INFO_CHANNEL(&server->config.logger, channel,
                                 "Client requested a subscription, " \
                                 "but those are not enabled in the build");
         } else {
-            UA_LOG_INFO_CHANNEL(server->config.logger, channel,
+            UA_LOG_INFO_CHANNEL(&server->config.logger, channel,
                                 "Unknown request with type identifier %i",
                                 requestTypeId.identifier.numeric);
         }
@@ -439,7 +440,7 @@ processMSG(UA_Server *server, UA_SecureChannel *channel,
     UA_RequestHeader *requestHeader = (UA_RequestHeader*)request;
     retval = UA_decodeBinary(msg, &offset, request, requestType, server->config.customDataTypes);
     if(retval != UA_STATUSCODE_GOOD) {
-        UA_LOG_DEBUG_CHANNEL(server->config.logger, channel,
+        UA_LOG_DEBUG_CHANNEL(&server->config.logger, channel,
                              "Could not decode the request");
         return sendServiceFault(channel, msg, requestPos, responseType, requestId, retval);
     }
@@ -479,7 +480,7 @@ processMSG(UA_Server *server, UA_SecureChannel *channel,
 
     if(requestType == &UA_TYPES[UA_TYPES_ACTIVATESESSIONREQUEST]) {
         if(!session) {
-            UA_LOG_DEBUG_CHANNEL(server->config.logger, channel,
+            UA_LOG_DEBUG_CHANNEL(&server->config.logger, channel,
                                  "Trying to activate a session that is " \
                                  "not known in the server");
             UA_deleteMembers(request, requestType);
@@ -496,7 +497,7 @@ processMSG(UA_Server *server, UA_SecureChannel *channel,
     UA_Session anonymousSession;
     if(!session) {
         if(sessionRequired) {
-            UA_LOG_WARNING_CHANNEL(server->config.logger, channel,
+            UA_LOG_WARNING_CHANNEL(&server->config.logger, channel,
                                    "Service request %i without a valid session",
                                    requestType->binaryEncodingId);
             UA_deleteMembers(request, requestType);
@@ -512,7 +513,7 @@ processMSG(UA_Server *server, UA_SecureChannel *channel,
 
     /* Trying to use a non-activated session? */
     if(sessionRequired && !session->activated) {
-        UA_LOG_WARNING_SESSION(server->config.logger, session,
+        UA_LOG_WARNING_SESSION(&server->config.logger, session,
                                "Calling service %i on a non-activated session",
                                requestType->binaryEncodingId);
         UA_SessionManager_removeSession(&server->sessionManager,
@@ -524,7 +525,7 @@ processMSG(UA_Server *server, UA_SecureChannel *channel,
 
     /* The session is bound to another channel */
     if(session != &anonymousSession && session->header.channel != channel) {
-        UA_LOG_WARNING_CHANNEL(server->config.logger, channel,
+        UA_LOG_WARNING_CHANNEL(&server->config.logger, channel,
                                "Client tries to use a Session that is not "
                                "bound to this SecureChannel");
         UA_deleteMembers(request, requestType);
@@ -598,7 +599,7 @@ processMSG(UA_Server *server, UA_SecureChannel *channel,
 
  cleanup:
     if(retval != UA_STATUSCODE_GOOD)
-        UA_LOG_INFO_CHANNEL(server->config.logger, channel,
+        UA_LOG_INFO_CHANNEL(&server->config.logger, channel,
                             "Could not send the message over the SecureChannel "
                             "with StatusCode %s", UA_StatusCode_name(retval));
     /* Clean up */
@@ -616,25 +617,25 @@ processSecureChannelMessage(void *application, UA_SecureChannel *channel,
     UA_StatusCode retval = UA_STATUSCODE_GOOD;
     switch(messagetype) {
     case UA_MESSAGETYPE_OPN:
-        UA_LOG_TRACE_CHANNEL(server->config.logger, channel,
+        UA_LOG_TRACE_CHANNEL(&server->config.logger, channel,
                              "Process an OPN on an open channel");
         retval = processOPN(server, channel, requestId, message);
         break;
     case UA_MESSAGETYPE_MSG:
-        UA_LOG_TRACE_CHANNEL(server->config.logger, channel, "Process a MSG");
+        UA_LOG_TRACE_CHANNEL(&server->config.logger, channel, "Process a MSG");
         retval = processMSG(server, channel, requestId, message);
         break;
     case UA_MESSAGETYPE_CLO:
-        UA_LOG_TRACE_CHANNEL(server->config.logger, channel, "Process a CLO");
+        UA_LOG_TRACE_CHANNEL(&server->config.logger, channel, "Process a CLO");
         Service_CloseSecureChannel(server, channel);
         break;
     default:
-        UA_LOG_TRACE_CHANNEL(server->config.logger, channel, "Invalid message type");
+        UA_LOG_TRACE_CHANNEL(&server->config.logger, channel, "Invalid message type");
         retval = UA_STATUSCODE_BADTCPMESSAGETYPEINVALID;
         break;
     }
     if(retval != UA_STATUSCODE_GOOD) {
-        UA_LOG_INFO_CHANNEL(server->config.logger, channel,
+        UA_LOG_INFO_CHANNEL(&server->config.logger, channel,
                             "Processing the message failed with StatusCode %s. "
                             "Closing the channel.", UA_StatusCode_name(retval));
         Service_CloseSecureChannel(server, channel);
@@ -679,7 +680,7 @@ static UA_StatusCode
 processCompleteChunkWithoutChannel(UA_Server *server, UA_Connection *connection,
                                    UA_ByteString *message) {
     /* Process chunk without a channel; must be OPN */
-    UA_LOG_TRACE(server->config.logger, UA_LOGCATEGORY_NETWORK,
+    UA_LOG_TRACE(&server->config.logger, UA_LOGCATEGORY_NETWORK,
                  "Connection %i | No channel attached to the connection. "
                  "Process the chunk directly", (int)(connection->sockfd));
     size_t offset = 0;
@@ -696,7 +697,7 @@ processCompleteChunkWithoutChannel(UA_Server *server, UA_Connection *connection,
         break;
     case UA_MESSAGETYPE_OPN:
     {
-        UA_LOG_TRACE(server->config.logger, UA_LOGCATEGORY_NETWORK,
+        UA_LOG_TRACE(&server->config.logger, UA_LOGCATEGORY_NETWORK,
                      "Connection %i | Process OPN message", (int)(connection->sockfd));
 
         /* Called before HEL */
@@ -730,7 +731,7 @@ processCompleteChunkWithoutChannel(UA_Server *server, UA_Connection *connection,
         break;
     }
     default:
-        UA_LOG_TRACE(server->config.logger, UA_LOGCATEGORY_NETWORK,
+        UA_LOG_TRACE(&server->config.logger, UA_LOGCATEGORY_NETWORK,
                      "Connection %i | Expected OPN or HEL message on a connection "
                      "without a SecureChannel", (int)(connection->sockfd));
         retval = UA_STATUSCODE_BADTCPMESSAGETYPEINVALID;
@@ -754,7 +755,7 @@ processCompleteChunk(void *const application, UA_Connection *connection,
 void
 UA_Server_processBinaryMessage(UA_Server *server, UA_Connection *connection,
                                UA_ByteString *message) {
-    UA_LOG_TRACE(server->config.logger, UA_LOGCATEGORY_NETWORK,
+    UA_LOG_TRACE(&server->config.logger, UA_LOGCATEGORY_NETWORK,
                  "Connection %i | Received a packet.", (int)(connection->sockfd));
 #ifdef UA_DEBUG_DUMP_PKGS
     UA_dump_hex_pkg(message->data, message->length);
@@ -763,7 +764,7 @@ UA_Server_processBinaryMessage(UA_Server *server, UA_Connection *connection,
     UA_StatusCode retval = UA_Connection_processChunks(connection, server,
                                                        processCompleteChunk, message);
     if(retval != UA_STATUSCODE_GOOD) {
-        UA_LOG_INFO(server->config.logger, UA_LOGCATEGORY_NETWORK,
+        UA_LOG_INFO(&server->config.logger, UA_LOGCATEGORY_NETWORK,
                     "Connection %i | Processing the message failed with "
                     "error %s", (int)(connection->sockfd), UA_StatusCode_name(retval));
         /* Send an ERR message and close the connection */

+ 2 - 2
src/server/ua_server_discovery.c

@@ -34,7 +34,7 @@ register_server_with_discovery_server(UA_Server *server,
         request.server.semaphoreFilePath =
             UA_STRING((char*)(uintptr_t)semaphoreFilePath); /* dirty cast */
 #else
-        UA_LOG_WARNING(server->config.logger, UA_LOGCATEGORY_CLIENT,
+        UA_LOG_WARNING(&server->config.logger, UA_LOGCATEGORY_CLIENT,
                        "Ignoring semaphore file path. open62541 not compiled "
                        "with UA_ENABLE_DISCOVERY_SEMAPHORE=ON");
 #endif
@@ -104,7 +104,7 @@ register_server_with_discovery_server(UA_Server *server,
     }
 
     if(serviceResult != UA_STATUSCODE_GOOD) {
-        UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_CLIENT,
+        UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_CLIENT,
                      "RegisterServer/RegisterServer2 failed with statuscode %s",
                      UA_StatusCode_name(serviceResult));
     }

+ 8 - 8
src/server/ua_server_discovery_mdns.c

@@ -185,7 +185,7 @@ getInterfaces(UA_Server *server) {
         /* todo: malloc may fail: return a statuscode */
         adapter_addresses = (IP_ADAPTER_ADDRESSES*)UA_malloc(adapter_addresses_buffer_size);
         if(!adapter_addresses) {
-            UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER,
+            UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER,
                          "GetAdaptersAddresses out of memory");
             adapter_addresses = NULL;
             break;
@@ -207,7 +207,7 @@ getInterfaces(UA_Server *server) {
         }
 
         /* Unexpected error */
-        UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER,
                      "GetAdaptersAddresses returned an unexpected error. "
                      "Not setting mDNS A records.");
         UA_free(adapter_addresses);
@@ -245,14 +245,14 @@ mdns_is_self_announce(UA_Server *server, struct serverOnNetwork_list_entry *entr
 #ifdef _WIN32
     IP_ADAPTER_ADDRESSES* adapter_addresses = getInterfaces(server);
     if(!adapter_addresses) {
-        UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER,
                      "getifaddrs returned an unexpected error. Not setting mDNS A records.");
         return false;
     }
 #else
     struct ifaddrs *ifaddr, *ifa;
     if(getifaddrs(&ifaddr) == -1) {
-        UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER,
                      "getifaddrs returned an unexpected error. Not setting mDNS A records.");
         return false;
     }
@@ -493,7 +493,7 @@ setSrv(UA_Server *server, const struct resource *r,
             char ipinput[INET_ADDRSTRLEN];
             inet_ntop(AF_INET, &(hostnameEntry->addr), ipinput, INET_ADDRSTRLEN);
             UA_LOG_SOCKET_ERRNO_WRAP(
-                UA_LOG_DEBUG(server->config.logger, UA_LOGCATEGORY_SERVER,
+                UA_LOG_DEBUG(&server->config.logger, UA_LOGCATEGORY_SERVER,
                              "Multicast: Can not resolve IP address to hostname: "
                              "%s - %s. Using IP instead",ipinput, errno_str));
 
@@ -515,7 +515,7 @@ setSrv(UA_Server *server, const struct resource *r,
     }
 
 
-    UA_LOG_INFO(server->config.logger, UA_LOGCATEGORY_SERVER,
+    UA_LOG_INFO(&server->config.logger, UA_LOGCATEGORY_SERVER,
                 "Multicast DNS: found server: %s", newUrl);
     entry->serverOnNetwork.discoveryUrl = UA_String_fromChars(newUrl);
     UA_free(newUrl);
@@ -574,7 +574,7 @@ mdns_record_received(const struct resource *r, void *data) {
 
     /* Check that the ttl is positive */
     if(r->ttl == 0) {
-        UA_LOG_INFO(server->config.logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_INFO(&server->config.logger, UA_LOGCATEGORY_SERVER,
                     "Multicast DNS: remove server (TTL=0): %.*s",
                     (int)entry->serverOnNetwork.discoveryUrl.length,
                     entry->serverOnNetwork.discoveryUrl.data);
@@ -760,7 +760,7 @@ mdns_set_address_record(UA_Server *server, const char *fullServiceDomain,
                         const char *localDomain) {
     struct ifaddrs *ifaddr, *ifa;
     if(getifaddrs(&ifaddr) == -1) {
-        UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER,
                      "getifaddrs returned an unexpected error. Not setting mDNS A records.");
         return;
     }

+ 2 - 2
src/server/ua_server_ns0.c

@@ -585,7 +585,7 @@ UA_Server_initNS0(UA_Server *server) {
 #endif
 
     if(retVal != UA_STATUSCODE_GOOD) {
-        UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER,
                      "Initialization of Namespace 0 (before bootstrapping) "
                      "failed with %s. See previous outputs for any error messages.",
                      UA_StatusCode_name(retVal));
@@ -851,7 +851,7 @@ UA_Server_initNS0(UA_Server *server) {
 #endif
 
     if(retVal != UA_STATUSCODE_GOOD) {
-        UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER,
                      "Initialization of Namespace 0 (after bootstrapping) "
                      "failed with %s. See previous outputs for any error messages.",
                      UA_StatusCode_name(retVal));

+ 15 - 14
src/server/ua_services_attribute.c

@@ -198,7 +198,7 @@ void
 ReadWithNode(const UA_Node *node, UA_Server *server, UA_Session *session,
              UA_TimestampsToReturn timestampsToReturn,
              const UA_ReadValueId *id, UA_DataValue *v) {
-    UA_LOG_DEBUG_SESSION(server->config.logger, session,
+    UA_LOG_DEBUG_SESSION(&server->config.logger, session,
                          "Read the attribute %i", id->attributeId);
 
     /* Only Binary Encoding is supported */
@@ -403,7 +403,7 @@ Operation_Read(UA_Server *server, UA_Session *session, UA_MessageContext *mc,
 
 UA_StatusCode Service_Read(UA_Server *server, UA_Session *session, UA_MessageContext *mc,
                            const UA_ReadRequest *request, UA_ResponseHeader *responseHeader) {
-    UA_LOG_DEBUG_SESSION(server->config.logger, session,
+    UA_LOG_DEBUG_SESSION(&server->config.logger, session,
                          "Processing ReadRequest");
 
     /* Check if the timestampstoreturn is valid */
@@ -637,7 +637,8 @@ compatibleValueRankArrayDimensions(UA_Server *server, UA_Session *session,
                                    UA_Int32 valueRank, size_t arrayDimensionsSize) {
     /* ValueRank invalid */
     if(valueRank < UA_VALUERANK_SCALAR_OR_ONE_DIMENSION) {
-        UA_LOG_INFO_SESSION(server->config.logger, session, "The ValueRank is invalid (< -3)");
+        UA_LOG_INFO_SESSION(&server->config.logger, session,
+                            "The ValueRank is invalid (< -3)");
         return false;
     }
 
@@ -647,7 +648,7 @@ compatibleValueRankArrayDimensions(UA_Server *server, UA_Session *session,
     /* case  0, UA_VALUERANK_ONE_OR_MORE_DIMENSIONS:  the value is an array with one or more dimensions */
     if(valueRank <= UA_VALUERANK_ONE_OR_MORE_DIMENSIONS) {
         if(arrayDimensionsSize > 0) {
-            UA_LOG_INFO_SESSION(server->config.logger, session,
+            UA_LOG_INFO_SESSION(&server->config.logger, session,
                                 "No ArrayDimensions can be defined for a ValueRank <= 0");
             return false;
         }
@@ -656,7 +657,7 @@ compatibleValueRankArrayDimensions(UA_Server *server, UA_Session *session,
     
     /* case >= 1, UA_VALUERANK_ONE_DIMENSION: the value is an array with the specified number of dimensions */
     if(arrayDimensionsSize != (size_t)valueRank) {
-        UA_LOG_INFO_SESSION(server->config.logger, session,
+        UA_LOG_INFO_SESSION(&server->config.logger, session,
                             "The number of ArrayDimensions is not equal to the (positive) ValueRank");
         return false;
     }
@@ -779,13 +780,13 @@ compatibleValue(UA_Server *server, UA_Session *session, const UA_NodeId *targetD
          * variables with no value, e.g. OldValues - ns=0;i=3024. See also
          * #1889, https://github.com/open62541/open62541/pull/1889#issuecomment-403506538 */
         if(server->config.relaxEmptyValueConstraint) {
-            UA_LOG_DEBUG_SESSION(server->config.logger, session,
+            UA_LOG_DEBUG_SESSION(&server->config.logger, session,
                                  "Only Variables with data type BaseDataType can contain an "
                                  "empty value. Allow via explicit constraint relaxation.");
             return true;
         }
 
-        UA_LOG_INFO_SESSION(server->config.logger, session,
+        UA_LOG_INFO_SESSION(&server->config.logger, session,
                             "Only Variables with data type BaseDataType can contain an empty value");
         return false;
     }
@@ -853,14 +854,14 @@ writeArrayDimensionsAttribute(UA_Server *server, UA_Session *session,
      * when we do the change */
     if(node->nodeClass == UA_NODECLASS_VARIABLETYPE &&
        UA_Node_hasSubTypeOrInstances((UA_Node*)node)) {
-        UA_LOG_INFO(server->config.logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_INFO(&server->config.logger, UA_LOGCATEGORY_SERVER,
                     "Cannot change a variable type with existing instances");
         return UA_STATUSCODE_BADINTERNALERROR;
     }
 
     /* Check that the array dimensions match with the valuerank */
     if(!compatibleValueRankArrayDimensions(server, session, node->valueRank, arrayDimensionsSize)) {
-        UA_LOG_DEBUG(server->config.logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_DEBUG(&server->config.logger, UA_LOGCATEGORY_SERVER,
                      "Cannot write the ArrayDimensions. The ValueRank does not match.");
         return UA_STATUSCODE_BADTYPEMISMATCH;
     }
@@ -870,7 +871,7 @@ writeArrayDimensionsAttribute(UA_Server *server, UA_Session *session,
     if(type->arrayDimensions &&
        !compatibleArrayDimensions(type->arrayDimensionsSize, type->arrayDimensions,
                                   arrayDimensionsSize, arrayDimensions)) {
-       UA_LOG_DEBUG(server->config.logger, UA_LOGCATEGORY_SERVER,
+       UA_LOG_DEBUG(&server->config.logger, UA_LOGCATEGORY_SERVER,
                     "Array dimensions in the variable type do not match");
        return UA_STATUSCODE_BADTYPEMISMATCH;
     }
@@ -886,7 +887,7 @@ writeArrayDimensionsAttribute(UA_Server *server, UA_Session *session,
             retval = UA_STATUSCODE_BADTYPEMISMATCH;
         UA_DataValue_deleteMembers(&value);
         if(retval != UA_STATUSCODE_GOOD) {
-            UA_LOG_DEBUG(server->config.logger, UA_LOGCATEGORY_SERVER,
+            UA_LOG_DEBUG(&server->config.logger, UA_LOGCATEGORY_SERVER,
                          "Array dimensions in the current value do not match");
             return retval;
         }
@@ -983,7 +984,7 @@ writeDataTypeAttribute(UA_Server *server, UA_Session *session,
             retval = UA_STATUSCODE_BADTYPEMISMATCH;
         UA_DataValue_deleteMembers(&value);
         if(retval != UA_STATUSCODE_GOOD) {
-            UA_LOG_DEBUG(server->config.logger, UA_LOGCATEGORY_SERVER,
+            UA_LOG_DEBUG(&server->config.logger, UA_LOGCATEGORY_SERVER,
                          "The current value does not match the new data type");
             return retval;
         }
@@ -1352,7 +1353,7 @@ copyAttributeIntoNode(UA_Server *server, UA_Session *session,
         break;
     }
     if(retval != UA_STATUSCODE_GOOD)
-        UA_LOG_INFO_SESSION(server->config.logger, session,
+        UA_LOG_INFO_SESSION(&server->config.logger, session,
                             "WriteRequest returned status code %s",
                             UA_StatusCode_name(retval));
     return retval;
@@ -1369,7 +1370,7 @@ void
 Service_Write(UA_Server *server, UA_Session *session,
               const UA_WriteRequest *request,
               UA_WriteResponse *response) {
-    UA_LOG_DEBUG_SESSION(server->config.logger, session,
+    UA_LOG_DEBUG_SESSION(&server->config.logger, session,
                          "Processing WriteRequest");
 
     if(server->config.maxNodesPerWrite != 0 &&

+ 19 - 19
src/server/ua_services_discovery.c

@@ -117,7 +117,7 @@ setApplicationDescriptionFromServer(UA_ApplicationDescription *target, const UA_
 void Service_FindServers(UA_Server *server, UA_Session *session,
                          const UA_FindServersRequest *request,
                          UA_FindServersResponse *response) {
-    UA_LOG_DEBUG_SESSION(server->config.logger, session, "Processing FindServersRequest");
+    UA_LOG_DEBUG_SESSION(&server->config.logger, session, "Processing FindServersRequest");
 
     /* Return the server itself? */
     UA_Boolean foundSelf = false;
@@ -217,11 +217,11 @@ Service_GetEndpoints(UA_Server *server, UA_Session *session,
        not, clone the endpoints with the discovery url of all networklayers. */
     const UA_String *endpointUrl = &request->endpointUrl;
     if(endpointUrl->length > 0) {
-        UA_LOG_DEBUG_SESSION(server->config.logger, session,
+        UA_LOG_DEBUG_SESSION(&server->config.logger, session,
                              "Processing GetEndpointsRequest with endpointUrl "
                              UA_PRINTF_STRING_FORMAT, UA_PRINTF_STRING_DATA(*endpointUrl));
     } else {
-        UA_LOG_DEBUG_SESSION(server->config.logger, session,
+        UA_LOG_DEBUG_SESSION(&server->config.logger, session,
                              "Processing GetEndpointsRequest with an empty endpointUrl");
     }
 
@@ -365,8 +365,8 @@ process_RegisterServer(UA_Server *server, UA_Session *session,
         char* filePath = (char*)
             UA_malloc(sizeof(char)*requestServer->semaphoreFilePath.length+1);
         if(!filePath) {
-            UA_LOG_ERROR_SESSION(server->config.logger, session,
-                                   "Cannot allocate memory for semaphore path. Out of memory.");
+            UA_LOG_ERROR_SESSION(&server->config.logger, session,
+                                 "Cannot allocate memory for semaphore path. Out of memory.");
             responseHeader->serviceResult = UA_STATUSCODE_BADOUTOFMEMORY;
             return;
         }
@@ -379,7 +379,7 @@ process_RegisterServer(UA_Server *server, UA_Session *session,
         }
         UA_free(filePath);
 #else
-        UA_LOG_WARNING(server->config.logger, UA_LOGCATEGORY_CLIENT,
+        UA_LOG_WARNING(&server->config.logger, UA_LOGCATEGORY_CLIENT,
                        "Ignoring semaphore file path. open62541 not compiled "
                        "with UA_ENABLE_DISCOVERY_SEMAPHORE=ON");
 #endif
@@ -402,7 +402,7 @@ process_RegisterServer(UA_Server *server, UA_Session *session,
         // server is shutting down. Remove it from the registered servers list
         if(!registeredServer_entry) {
             // server not found, show warning
-            UA_LOG_WARNING_SESSION(server->config.logger, session,
+            UA_LOG_WARNING_SESSION(&server->config.logger, session,
                                    "Could not unregister server %.*s. Not registered.",
                                    (int)requestServer->serverUri.length, requestServer->serverUri.data);
             responseHeader->serviceResult = UA_STATUSCODE_BADNOTHINGTODO;
@@ -432,7 +432,7 @@ process_RegisterServer(UA_Server *server, UA_Session *session,
     UA_StatusCode retval = UA_STATUSCODE_GOOD;
     if(!registeredServer_entry) {
         // server not yet registered, register it by adding it to the list
-        UA_LOG_DEBUG_SESSION(server->config.logger, session, "Registering new server: %.*s",
+        UA_LOG_DEBUG_SESSION(&server->config.logger, session, "Registering new server: %.*s",
                              (int)requestServer->serverUri.length, requestServer->serverUri.data);
 
         registeredServer_entry =
@@ -466,7 +466,7 @@ process_RegisterServer(UA_Server *server, UA_Session *session,
 void Service_RegisterServer(UA_Server *server, UA_Session *session,
                             const UA_RegisterServerRequest *request,
                             UA_RegisterServerResponse *response) {
-    UA_LOG_DEBUG_SESSION(server->config.logger, session,
+    UA_LOG_DEBUG_SESSION(&server->config.logger, session,
                          "Processing RegisterServerRequest");
     process_RegisterServer(server, session, &request->requestHeader, &request->server, 0,
                            NULL, &response->responseHeader, 0, NULL, 0, NULL);
@@ -475,7 +475,7 @@ void Service_RegisterServer(UA_Server *server, UA_Session *session,
 void Service_RegisterServer2(UA_Server *server, UA_Session *session,
                             const UA_RegisterServer2Request *request,
                              UA_RegisterServer2Response *response) {
-    UA_LOG_DEBUG_SESSION(server->config.logger, session,
+    UA_LOG_DEBUG_SESSION(&server->config.logger, session,
                          "Processing RegisterServer2Request");
     process_RegisterServer(server, session, &request->requestHeader, &request->server,
                            request->discoveryConfigurationSize, request->discoveryConfiguration,
@@ -511,7 +511,7 @@ void UA_Discovery_cleanupTimedOut(UA_Server *server, UA_DateTime nowMonotonic) {
                 semaphoreDeleted = UA_fileExists(filePath) == false;
                 UA_free(filePath);
             } else {
-                UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER,
+                UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER,
                              "Cannot check registration semaphore. Out of memory");
             }
         }
@@ -520,7 +520,7 @@ void UA_Discovery_cleanupTimedOut(UA_Server *server, UA_DateTime nowMonotonic) {
         if(semaphoreDeleted || (server->config.discoveryCleanupTimeout &&
                                 current->lastSeen < timedOut)) {
             if(semaphoreDeleted) {
-                UA_LOG_INFO(server->config.logger, UA_LOGCATEGORY_SERVER,
+                UA_LOG_INFO(&server->config.logger, UA_LOGCATEGORY_SERVER,
                             "Registration of server with URI %.*s is removed because "
                             "the semaphore file '%.*s' was deleted.",
                             (int)current->registeredServer.serverUri.length,
@@ -529,7 +529,7 @@ void UA_Discovery_cleanupTimedOut(UA_Server *server, UA_DateTime nowMonotonic) {
                             current->registeredServer.semaphoreFilePath.data);
             } else {
                 // cppcheck-suppress unreadVariable
-                UA_LOG_INFO(server->config.logger, UA_LOGCATEGORY_SERVER,
+                UA_LOG_INFO(&server->config.logger, UA_LOGCATEGORY_SERVER,
                             "Registration of server with URI %.*s has timed out and is removed.",
                             (int)current->registeredServer.serverUri.length,
                             current->registeredServer.serverUri.data);
@@ -594,14 +594,14 @@ periodicServerRegister(UA_Server *server, void *data) {
     if (cb->client->state == UA_CLIENTSTATE_CONNECTED) {
         UA_StatusCode retval1 = UA_Client_disconnect(cb->client);
         if(retval1 != UA_STATUSCODE_GOOD) {
-            UA_LOG_WARNING(server->config.logger, UA_LOGCATEGORY_SERVER,
+            UA_LOG_WARNING(&server->config.logger, UA_LOGCATEGORY_SERVER,
                          "Could not disconnect client from register server. StatusCode %s",
                          UA_StatusCode_name(retval));
         }
     }
     /* Registering failed */
     if(retval != UA_STATUSCODE_GOOD) {
-        UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER,
                      "Could not register server with discovery server. "
                      "Is the discovery server started? StatusCode %s",
                      UA_StatusCode_name(retval));
@@ -622,7 +622,7 @@ periodicServerRegister(UA_Server *server, void *data) {
     }
 
     /* Registering succeeded */
-    UA_LOG_DEBUG(server->config.logger, UA_LOGCATEGORY_SERVER,
+    UA_LOG_DEBUG(&server->config.logger, UA_LOGCATEGORY_SERVER,
                  "Server successfully registered. Next periodical register will be in %d seconds",
                  (int)(cb->default_interval/1000));
 
@@ -644,7 +644,7 @@ UA_Server_addPeriodicServerRegisterCallback(UA_Server *server,
 
     /* No valid server URL */
     if(!discoveryServerUrl) {
-        UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER,
                      "No discovery server URL provided");
         return UA_STATUSCODE_BADINTERNALERROR;
     }
@@ -659,7 +659,7 @@ UA_Server_addPeriodicServerRegisterCallback(UA_Server *server,
         LIST_FOREACH_SAFE(rs, &server->discoveryManager.
                           periodicServerRegisterCallbacks, pointers, rs_tmp) {
             if(strcmp(rs->callback->discovery_server_url, discoveryServerUrl) == 0) {
-                UA_LOG_INFO(server->config.logger, UA_LOGCATEGORY_SERVER,
+                UA_LOG_INFO(&server->config.logger, UA_LOGCATEGORY_SERVER,
                             "There is already a register callback for '%s' in place. Removing the older one.", discoveryServerUrl);
                 UA_Server_removeRepeatedCallback(server, rs->callback->id);
                 LIST_REMOVE(rs, pointers);
@@ -693,7 +693,7 @@ UA_Server_addPeriodicServerRegisterCallback(UA_Server *server,
         UA_Server_addRepeatedCallback(server, periodicServerRegister,
                                       cb, delayFirstRegisterMs, &cb->id);
     if(retval != UA_STATUSCODE_GOOD) {
-        UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER,
                      "Could not create periodic job for server register. "
                      "StatusCode %s", UA_StatusCode_name(retval));
         UA_free(cb);

+ 20 - 20
src/server/ua_services_discovery_multicast.c

@@ -33,12 +33,12 @@ multicastWorkerLoop(UA_Server *server) {
                        FD_ISSET(server->discoveryManager.mdnsSocket, &fds), true, &next_sleep);
         if(retVal == 1) {
             UA_LOG_SOCKET_ERRNO_WRAP(
-                UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER,
+                UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER,
                           "Multicast error: Can not read from socket. %s", errno_str));
             break;
         } else if (retVal == 2) {
             UA_LOG_SOCKET_ERRNO_WRAP(
-                UA_LOG_DEBUG(server->config.logger, UA_LOGCATEGORY_SERVER,
+                UA_LOG_DEBUG(&server->config.logger, UA_LOGCATEGORY_SERVER,
                          "Multicast error: Can not write to socket. %s", errno_str));
             break;
         }
@@ -51,7 +51,7 @@ multicastListenStart(UA_Server* server) {
     int err = pthread_create(&server->discoveryManager.mdnsThread, NULL,
                              (void* (*)(void*))multicastWorkerLoop, server);
     if(err != 0) {
-        UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER,
                      "Multicast error: Can not create multicast thread.");
         return UA_STATUSCODE_BADUNEXPECTEDERROR;
     }
@@ -64,7 +64,7 @@ multicastListenStop(UA_Server* server) {
     // wake up select
     if(write(server->discoveryManager.mdnsSocket, "\0", 1)){}; //TODO: move to arch?
     if(pthread_join(server->discoveryManager.mdnsThread, NULL)) {
-        UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER,
                      "Multicast error: Can not stop thread.");
         return UA_STATUSCODE_BADUNEXPECTEDERROR;
     }
@@ -82,7 +82,7 @@ addMdnsRecordForNetworkLayer(UA_Server *server, const UA_String *appName,
     UA_StatusCode retval = UA_parseEndpointUrl(&nl->discoveryUrl, &hostname,
                                                &port, &path);
     if(retval != UA_STATUSCODE_GOOD) {
-        UA_LOG_WARNING(server->config.logger, UA_LOGCATEGORY_NETWORK,
+        UA_LOG_WARNING(&server->config.logger, UA_LOGCATEGORY_NETWORK,
                        "Server url is invalid: %.*s",
                        (int)nl->discoveryUrl.length, nl->discoveryUrl.data);
         return retval;
@@ -115,7 +115,7 @@ stopMulticastDiscoveryServer(UA_Server *server) {
         UA_Discovery_removeRecord(server, &server->config.mdnsServerName,
                                   &hnString, 4840, true);
     } else {
-        UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER,
                      "Could not get hostname for multicast discovery.");
     }
 
@@ -201,7 +201,7 @@ UA_Server_updateMdnsForDiscoveryUrl(UA_Server *server, const UA_String *serverNa
     UA_String path = UA_STRING_NULL;
     UA_StatusCode retval = UA_parseEndpointUrl(discoveryUrl, &hostname, &port, &path);
     if(retval != UA_STATUSCODE_GOOD) {
-        UA_LOG_WARNING(server->config.logger, UA_LOGCATEGORY_NETWORK,
+        UA_LOG_WARNING(&server->config.logger, UA_LOGCATEGORY_NETWORK,
                        "Server url invalid: %.*s",
                        (int)discoveryUrl->length, discoveryUrl->data);
         return;
@@ -212,7 +212,7 @@ UA_Server_updateMdnsForDiscoveryUrl(UA_Server *server, const UA_String *serverNa
                 UA_Discovery_removeRecord(server, serverName, &hostname,
                                           port, updateTxt);
         if(removeRetval != UA_STATUSCODE_GOOD)
-            UA_LOG_WARNING(server->config.logger, UA_LOGCATEGORY_SERVER,
+            UA_LOG_WARNING(&server->config.logger, UA_LOGCATEGORY_SERVER,
                            "Could not remove mDNS record for hostname %.*s.",
                            (int)serverName->length, serverName->data);
         return;
@@ -230,7 +230,7 @@ UA_Server_updateMdnsForDiscoveryUrl(UA_Server *server, const UA_String *serverNa
                                port, &path, UA_DISCOVERY_TCP, updateTxt,
                                capabilities, &capabilitiesSize);
     if(addRetval != UA_STATUSCODE_GOOD)
-        UA_LOG_WARNING(server->config.logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_WARNING(&server->config.logger, UA_LOGCATEGORY_SERVER,
                        "Could not add mDNS record for hostname %.*s.",
                        (int)serverName->length, serverName->data);
 }
@@ -247,7 +247,7 @@ static void
 UA_Discovery_multicastConflict(char *name, int type, void *arg) {
     // cppcheck-suppress unreadVariable
     UA_Server *server = (UA_Server*) arg;
-    UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER,
+    UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER,
                  "Multicast DNS name conflict detected: "
                  "'%s' for type %d", name, type);
 }
@@ -320,7 +320,7 @@ discovery_multicastQueryAnswer(mdns_answer_t *a, void *arg) {
     if(mdnsd_has_query(server->discoveryManager.mdnsDaemon, a->rdname))
         return 0;
 
-    UA_LOG_DEBUG(server->config.logger, UA_LOGCATEGORY_SERVER,
+    UA_LOG_DEBUG(&server->config.logger, UA_LOGCATEGORY_SERVER,
                  "mDNS send query for: %s SRV&TXT %s", a->name, a->rdname);
 
     mdnsd_query(server->discoveryManager.mdnsDaemon, a->rdname, QTYPE_SRV,
@@ -354,11 +354,11 @@ UA_Discovery_addRecord(UA_Server *server, const UA_String *servername,
     // use a limit for the hostname length to make sure full string fits into 63
     // chars (limited by DNS spec)
     if(hostnameLen+servernameLen + 1 > 63) { // include dash between servername-hostname
-        UA_LOG_WARNING(server->config.logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_WARNING(&server->config.logger, UA_LOGCATEGORY_SERVER,
                        "Multicast DNS: Combination of hostname+servername exceeds "
                        "maximum of 62 chars. It will be truncated.");
     } else if(hostnameLen > 63) {
-        UA_LOG_WARNING(server->config.logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_WARNING(&server->config.logger, UA_LOGCATEGORY_SERVER,
                        "Multicast DNS: Hostname length exceeds maximum of 63 chars. "
                        "It will be truncated.");
     }
@@ -379,7 +379,7 @@ UA_Discovery_addRecord(UA_Server *server, const UA_String *servername,
     if(exists == true)
         return UA_STATUSCODE_GOOD;
 
-    UA_LOG_INFO(server->config.logger, UA_LOGCATEGORY_SERVER,
+    UA_LOG_INFO(&server->config.logger, UA_LOGCATEGORY_SERVER,
                 "Multicast DNS: add record for domain: %s", fullServiceDomain);
 
     // _services._dns-sd._udp.local. PTR _opcua-tcp._tcp.local
@@ -435,7 +435,7 @@ UA_Discovery_removeRecord(UA_Server *server, const UA_String *servername,
         return UA_STATUSCODE_BADOUTOFRANGE;
 
     if(hostnameLen+servernameLen+1 > 63) { // include dash between servername-hostname
-        UA_LOG_WARNING(server->config.logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_WARNING(&server->config.logger, UA_LOGCATEGORY_SERVER,
                        "Multicast DNS: Combination of hostname+servername exceeds "
                        "maximum of 62 chars. It will be truncated.");
     }
@@ -444,14 +444,14 @@ UA_Discovery_removeRecord(UA_Server *server, const UA_String *servername,
     char fullServiceDomain[63 + 24];
     createFullServiceDomain(fullServiceDomain, 63+24, servername, hostname);
 
-    UA_LOG_INFO(server->config.logger, UA_LOGCATEGORY_SERVER,
+    UA_LOG_INFO(&server->config.logger, UA_LOGCATEGORY_SERVER,
                 "Multicast DNS: remove record for domain: %s", fullServiceDomain);
 
     // _opcua-tcp._tcp.local. PTR [servername]-[hostname]._opcua-tcp._tcp.local.
     mdns_record_t *r = mdns_find_record(server->discoveryManager.mdnsDaemon, QTYPE_PTR,
                                         "_opcua-tcp._tcp.local.", fullServiceDomain);
     if(!r) {
-        UA_LOG_WARNING(server->config.logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_WARNING(&server->config.logger, UA_LOGCATEGORY_SERVER,
                        "Multicast DNS: could not remove record. "
                        "PTR Record not found for domain: %s", fullServiceDomain);
         return UA_STATUSCODE_BADNOTHINGTODO;
@@ -463,7 +463,7 @@ UA_Discovery_removeRecord(UA_Server *server, const UA_String *servername,
     // and A record: [servername]-[hostname]._opcua-tcp._tcp.local. A [ip]
     mdns_record_t *r2 = mdnsd_get_published(server->discoveryManager.mdnsDaemon, fullServiceDomain);
     if(!r2) {
-        UA_LOG_WARNING(server->config.logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_WARNING(&server->config.logger, UA_LOGCATEGORY_SERVER,
                        "Multicast DNS: could not remove record. Record not "
                        "found for domain: %s", fullServiceDomain);
         return UA_STATUSCODE_BADNOTHINGTODO;
@@ -492,12 +492,12 @@ iterateMulticastDiscoveryServer(UA_Server* server, UA_DateTime *nextRepeat,
                                        processIn, true, &next_sleep);
     if(retval == 1) {
         UA_LOG_SOCKET_ERRNO_WRAP(
-               UA_LOG_DEBUG(server->config.logger, UA_LOGCATEGORY_SERVER,
+               UA_LOG_DEBUG(&server->config.logger, UA_LOGCATEGORY_SERVER,
                      "Multicast error: Can not read from socket. %s", errno_str));
         return UA_STATUSCODE_BADNOCOMMUNICATION;
     } else if(retval == 2) {
         UA_LOG_SOCKET_ERRNO_WRAP(
-                UA_LOG_DEBUG(server->config.logger, UA_LOGCATEGORY_SERVER,
+                UA_LOG_DEBUG(&server->config.logger, UA_LOGCATEGORY_SERVER,
                      "Multicast error: Can not write to socket. %s", errno_str));
         return UA_STATUSCODE_BADNOCOMMUNICATION;
     }

+ 55 - 53
src/server/ua_services_nodemanagement.c

@@ -26,7 +26,6 @@
     UA_String_deleteMembers(&nodeIdStr); \
 }
 
-
 /*********************/
 /* Edit Node Context */
 /*********************/
@@ -86,8 +85,9 @@ checkParentReference(UA_Server *server, UA_Session *session, UA_NodeClass nodeCl
     /* See if the parent exists */
     const UA_Node *parent = UA_Nodestore_get(server, parentNodeId);
     if(!parent) {
-        UA_LOG_NODEID_WRAP(parentNodeId, UA_LOG_INFO_SESSION(server->config.logger, session,
-                            "AddNodes: Parent node %.*s not found", (int)nodeIdStr.length, nodeIdStr.data));
+        UA_LOG_NODEID_WRAP(parentNodeId, UA_LOG_INFO_SESSION(&server->config.logger, session,
+                            "AddNodes: Parent node %.*s not found",
+                            (int)nodeIdStr.length, nodeIdStr.data));
         return UA_STATUSCODE_BADPARENTNODEIDINVALID;
     }
 
@@ -98,7 +98,7 @@ checkParentReference(UA_Server *server, UA_Session *session, UA_NodeClass nodeCl
     const UA_ReferenceTypeNode *referenceType = (const UA_ReferenceTypeNode*)
         UA_Nodestore_get(server, referenceTypeId);
     if(!referenceType) {
-        UA_LOG_NODEID_WRAP(referenceTypeId, UA_LOG_INFO_SESSION(server->config.logger, session,
+        UA_LOG_NODEID_WRAP(referenceTypeId, UA_LOG_INFO_SESSION(&server->config.logger, session,
                             "AddNodes: Reference type %.*s to the parent not found",
                             (int)nodeIdStr.length, nodeIdStr.data));
         return UA_STATUSCODE_BADREFERENCETYPEIDINVALID;
@@ -106,7 +106,7 @@ checkParentReference(UA_Server *server, UA_Session *session, UA_NodeClass nodeCl
 
     /* Check if the referencetype is a reference type node */
     if(referenceType->nodeClass != UA_NODECLASS_REFERENCETYPE) {
-        UA_LOG_NODEID_WRAP(referenceTypeId, UA_LOG_INFO_SESSION(server->config.logger, session,
+        UA_LOG_NODEID_WRAP(referenceTypeId, UA_LOG_INFO_SESSION(&server->config.logger, session,
                             "AddNodes: Reference type %.*s to the parent is not a ReferenceTypeNode",
                             (int)nodeIdStr.length, nodeIdStr.data));
         UA_Nodestore_release(server, (const UA_Node*)referenceType);
@@ -117,7 +117,7 @@ checkParentReference(UA_Server *server, UA_Session *session, UA_NodeClass nodeCl
     UA_Nodestore_release(server, (const UA_Node*)referenceType);
     /* Check that the reference type is not abstract */
     if(referenceTypeIsAbstract == true) {
-        UA_LOG_NODEID_WRAP(referenceTypeId, UA_LOG_INFO_SESSION(server->config.logger, session,
+        UA_LOG_NODEID_WRAP(referenceTypeId, UA_LOG_INFO_SESSION(&server->config.logger, session,
                             "AddNodes: Abstract reference type %.*s to the parent not allowed",
                             (int)nodeIdStr.length, nodeIdStr.data));
         return UA_STATUSCODE_BADREFERENCENOTALLOWED;
@@ -130,14 +130,16 @@ checkParentReference(UA_Server *server, UA_Session *session, UA_NodeClass nodeCl
        nodeClass == UA_NODECLASS_REFERENCETYPE) {
         /* type needs hassubtype reference to the supertype */
         if(!UA_NodeId_equal(referenceTypeId, &subtypeId)) {
-            UA_LOG_INFO_SESSION(server->config.logger, session,
-                                "AddNodes: Type nodes need to have a HasSubType reference to the parent");
+            UA_LOG_INFO_SESSION(&server->config.logger, session,
+                                "AddNodes: Type nodes need to have a HasSubType "
+                                "reference to the parent");
             return UA_STATUSCODE_BADREFERENCENOTALLOWED;
         }
         /* supertype needs to be of the same node type  */
         if(parentNodeClass != nodeClass) {
-            UA_LOG_INFO_SESSION(server->config.logger, session,
-                                "AddNodes: Type nodes needs to be of the same node type as their parent");
+            UA_LOG_INFO_SESSION(&server->config.logger, session,
+                                "AddNodes: Type nodes needs to be of the same node "
+                                "type as their parent");
             return UA_STATUSCODE_BADPARENTNODEIDINVALID;
         }
         return UA_STATUSCODE_GOOD;
@@ -146,7 +148,7 @@ checkParentReference(UA_Server *server, UA_Session *session, UA_NodeClass nodeCl
     /* Test if the referencetype is hierarchical */
     if(!isNodeInTree(&server->config.nodestore, referenceTypeId,
                      &hierarchicalReferences, &subtypeId, 1)) {
-        UA_LOG_INFO_SESSION(server->config.logger, session,
+        UA_LOG_INFO_SESSION(&server->config.logger, session,
                             "AddNodes: Reference type to the parent is not hierarchical");
         return UA_STATUSCODE_BADREFERENCETYPEIDINVALID;
     }
@@ -169,10 +171,10 @@ typeCheckVariableNode(UA_Server *server, UA_Session *session,
     /* Check the datatype against the vt */
     if(!compatibleDataType(server, &node->dataType, &vt->dataType, false)) {
 
-        UA_LOG_NODEID_WRAP(&node->nodeId, UA_LOG_INFO_SESSION(server->config.logger, session,
-                                                       "AddNodes: The value of %.*s is incompatible with "
-                                                       "the datatype of the VariableType",
-                                                       (int)nodeIdStr.length, nodeIdStr.data));
+        UA_LOG_NODEID_WRAP(&node->nodeId, UA_LOG_INFO_SESSION(&server->config.logger, session,
+                              "AddNodes: The value of %.*s is incompatible with "
+                              "the datatype of the VariableType",
+                              (int)nodeIdStr.length, nodeIdStr.data));
         return UA_STATUSCODE_BADTYPEMISMATCH;
     }
 
@@ -182,20 +184,20 @@ typeCheckVariableNode(UA_Server *server, UA_Session *session,
 
     /* Check valueRank against the vt */
     if(!compatibleValueRanks(node->valueRank, vt->valueRank)) {
-        UA_LOG_NODEID_WRAP(&node->nodeId, UA_LOG_INFO_SESSION(server->config.logger, session,
-                                                             "AddNodes: The value rank of %.*s is incomatible "
-                                                             "with the value rank of the VariableType",
-                                                             (int)nodeIdStr.length, nodeIdStr.data));
+        UA_LOG_NODEID_WRAP(&node->nodeId, UA_LOG_INFO_SESSION(&server->config.logger, session,
+                                 "AddNodes: The value rank of %.*s is incomatible "
+                                 "with the value rank of the VariableType",
+                                 (int)nodeIdStr.length, nodeIdStr.data));
         return UA_STATUSCODE_BADTYPEMISMATCH;
     }
 
     /* Check array dimensions against the vt */
     if(!compatibleArrayDimensions(vt->arrayDimensionsSize, vt->arrayDimensions,
                                   node->arrayDimensionsSize, node->arrayDimensions)) {
-        UA_LOG_NODEID_WRAP(&node->nodeId, UA_LOG_INFO_SESSION(server->config.logger, session,
-                                                             "AddNodes: The array dimensions of %.*s are "
-                                                             "incomatible with the array dimensions of the VariableType",
-                                                             (int)nodeIdStr.length, nodeIdStr.data));
+        UA_LOG_NODEID_WRAP(&node->nodeId, UA_LOG_INFO_SESSION(&server->config.logger, session,
+                                    "AddNodes: The array dimensions of %.*s are "
+                                    "incomatible with the array dimensions of the VariableType",
+                                    (int)nodeIdStr.length, nodeIdStr.data));
         return UA_STATUSCODE_BADTYPEMISMATCH;
     }
 
@@ -244,7 +246,7 @@ useVariableTypeAttributes(UA_Server *server, UA_Session *session,
         /* A value is present */
         UA_DataValue_deleteMembers(&orig);
     } else {
-        UA_LOG_DEBUG_SESSION(server->config.logger, session,
+        UA_LOG_DEBUG_SESSION(&server->config.logger, session,
                              "AddNodes: No value given; Copy the value "
                              "from the TypeDefinition");
         UA_WriteValue v;
@@ -264,7 +266,7 @@ useVariableTypeAttributes(UA_Server *server, UA_Session *session,
 
     /* If no datatype is given, use the datatype of the vt */
     if(UA_NodeId_isNull(&node->dataType)) {
-        UA_LOG_INFO_SESSION(server->config.logger, session, "AddNodes: "
+        UA_LOG_INFO_SESSION(&server->config.logger, session, "AddNodes: "
                             "No datatype given; Copy the datatype attribute "
                             "from the TypeDefinition");
         UA_WriteValue v;
@@ -647,7 +649,7 @@ AddNode_addRefs(UA_Server *server, UA_Session *session, const UA_NodeId *nodeId,
     UA_StatusCode retval = checkParentReference(server, session, node->nodeClass,
                                                 parentNodeId, referenceTypeId);
     if(retval != UA_STATUSCODE_GOOD) {
-        UA_LOG_NODEID_WRAP(nodeId, UA_LOG_INFO_SESSION(server->config.logger, session,
+        UA_LOG_NODEID_WRAP(nodeId, UA_LOG_INFO_SESSION(&server->config.logger, session,
                             "AddNodes: The parent reference for %.*s is invalid "
                             "with status code %s",
                             (int)nodeIdStr.length, nodeIdStr.data,
@@ -659,7 +661,7 @@ AddNode_addRefs(UA_Server *server, UA_Session *session, const UA_NodeId *nodeId,
     if((node->nodeClass == UA_NODECLASS_VARIABLE ||
         node->nodeClass == UA_NODECLASS_OBJECT) &&
        UA_NodeId_isNull(typeDefinitionId)) {
-        UA_LOG_NODEID_WRAP(nodeId, UA_LOG_INFO_SESSION(server->config.logger, session,
+        UA_LOG_NODEID_WRAP(nodeId, UA_LOG_INFO_SESSION(&server->config.logger, session,
                             "AddNodes: No TypeDefinition for %.*s; Use the default "
                             "TypeDefinition for the Variable/Object",
                             (int)nodeIdStr.length, nodeIdStr.data));
@@ -675,7 +677,7 @@ AddNode_addRefs(UA_Server *server, UA_Session *session, const UA_NodeId *nodeId,
         /* Get the type node */
         type = UA_Nodestore_get(server, typeDefinitionId);
         if(!type) {
-            UA_LOG_NODEID_WRAP(typeDefinitionId, UA_LOG_INFO_SESSION(server->config.logger, session,
+            UA_LOG_NODEID_WRAP(typeDefinitionId, UA_LOG_INFO_SESSION(&server->config.logger, session,
                                 "AddNodes: Node type %.*s not found",
                                 (int)nodeIdStr.length, nodeIdStr.data));
             retval = UA_STATUSCODE_BADTYPEDEFINITIONINVALID;
@@ -712,7 +714,7 @@ AddNode_addRefs(UA_Server *server, UA_Session *session, const UA_NodeId *nodeId,
                 typeOk = false;
         }
         if(!typeOk) {
-            UA_LOG_NODEID_WRAP(nodeId, UA_LOG_INFO_SESSION(server->config.logger, session,
+            UA_LOG_NODEID_WRAP(nodeId, UA_LOG_INFO_SESSION(&server->config.logger, session,
                                 "AddNodes: Type for %.*s does not match node class",
                                 (int)nodeIdStr.length, nodeIdStr.data));
             retval = UA_STATUSCODE_BADTYPEDEFINITIONINVALID;
@@ -737,7 +739,7 @@ AddNode_addRefs(UA_Server *server, UA_Session *session, const UA_NodeId *nodeId,
                    !isNodeInTree(&server->config.nodestore, parentNodeId, &objectTypes,
                                  parentTypeHierachy,parentTypeHierachySize)) {
                     UA_Array_delete(parentTypeHierachy, parentTypeHierachySize, &UA_TYPES[UA_TYPES_NODEID]);
-                    UA_LOG_NODEID_WRAP(nodeId, UA_LOG_INFO_SESSION(server->config.logger, session,
+                    UA_LOG_NODEID_WRAP(nodeId, UA_LOG_INFO_SESSION(&server->config.logger, session,
                                         "AddNodes: Type of variable node %.*s must "
                                         "be VariableType and not cannot be abstract",
                                         (int)nodeIdStr.length, nodeIdStr.data));
@@ -763,7 +765,7 @@ AddNode_addRefs(UA_Server *server, UA_Session *session, const UA_NodeId *nodeId,
 
                 UA_Array_delete(parentTypeHierachy, parentTypeHierachySize, &UA_TYPES[UA_TYPES_NODEID]);
                 if(!isInBaseObjectType) {
-                    UA_LOG_NODEID_WRAP(nodeId, UA_LOG_INFO_SESSION(server->config.logger, session,
+                    UA_LOG_NODEID_WRAP(nodeId, UA_LOG_INFO_SESSION(&server->config.logger, session,
                                         "AddNodes: Type of object node %.*s must "
                                         "be ObjectType and not be abstract",
                                         (int)nodeIdStr.length, nodeIdStr.data));
@@ -777,7 +779,7 @@ AddNode_addRefs(UA_Server *server, UA_Session *session, const UA_NodeId *nodeId,
     /* Add reference to the parent */
     if(!UA_NodeId_isNull(parentNodeId)) {
         if(UA_NodeId_isNull(referenceTypeId)) {
-            UA_LOG_NODEID_WRAP(nodeId, UA_LOG_INFO_SESSION(server->config.logger, session,
+            UA_LOG_NODEID_WRAP(nodeId, UA_LOG_INFO_SESSION(&server->config.logger, session,
                                 "AddNodes: Reference to parent of %.*s cannot be null",
                                 (int)nodeIdStr.length, nodeIdStr.data));
             retval = UA_STATUSCODE_BADTYPEDEFINITIONINVALID;
@@ -786,7 +788,7 @@ AddNode_addRefs(UA_Server *server, UA_Session *session, const UA_NodeId *nodeId,
 
         retval = addRef(server, session, &node->nodeId, referenceTypeId, parentNodeId, false);
         if(retval != UA_STATUSCODE_GOOD) {
-            UA_LOG_NODEID_WRAP(nodeId, UA_LOG_INFO_SESSION(server->config.logger, session,
+            UA_LOG_NODEID_WRAP(nodeId, UA_LOG_INFO_SESSION(&server->config.logger, session,
                                 "AddNodes: Adding reference to parent of %.*s failed",
                                 (int)nodeIdStr.length, nodeIdStr.data));
             goto cleanup;
@@ -799,7 +801,7 @@ AddNode_addRefs(UA_Server *server, UA_Session *session, const UA_NodeId *nodeId,
         UA_assert(type != NULL); /* see above */
         retval = addRef(server, session, &node->nodeId, &hasTypeDefinition, &type->nodeId, true);
         if(retval != UA_STATUSCODE_GOOD) {
-            UA_LOG_NODEID_WRAP(nodeId, UA_LOG_INFO_SESSION(server->config.logger, session,
+            UA_LOG_NODEID_WRAP(nodeId, UA_LOG_INFO_SESSION(&server->config.logger, session,
                                 "AddNodes: Adding a reference to the type "
                                 "definition of %.*s failed with error code %s",
                                 (int)nodeIdStr.length, nodeIdStr.data,
@@ -828,14 +830,14 @@ AddNode_raw(UA_Server *server, UA_Session *session, void *nodeContext,
 
     /* Check the namespaceindex */
     if(item->requestedNewNodeId.nodeId.namespaceIndex >= server->namespacesSize) {
-        UA_LOG_INFO_SESSION(server->config.logger, session,
+        UA_LOG_INFO_SESSION(&server->config.logger, session,
                             "AddNodes: Namespace invalid");
         return UA_STATUSCODE_BADNODEIDINVALID;
     }
 
     if(item->nodeAttributes.encoding != UA_EXTENSIONOBJECT_DECODED &&
        item->nodeAttributes.encoding != UA_EXTENSIONOBJECT_DECODED_NODELETE) {
-        UA_LOG_INFO_SESSION(server->config.logger, session,
+        UA_LOG_INFO_SESSION(&server->config.logger, session,
                             "AddNodes: Node attributes invalid");
         return UA_STATUSCODE_BADINTERNALERROR;
     }
@@ -843,7 +845,7 @@ AddNode_raw(UA_Server *server, UA_Session *session, void *nodeContext,
     /* Create a node */
     UA_Node *node = UA_Nodestore_new(server, item->nodeClass);
     if(!node) {
-        UA_LOG_INFO_SESSION(server->config.logger, session,
+        UA_LOG_INFO_SESSION(&server->config.logger, session,
                             "AddNodes: Node could not create a node "
                             "in the nodestore");
         return UA_STATUSCODE_BADOUTOFMEMORY;
@@ -867,14 +869,14 @@ AddNode_raw(UA_Server *server, UA_Session *session, void *nodeContext,
     /* Add the node to the nodestore */
     retval = UA_Nodestore_insert(server, node, outNewNodeId);
     if(retval != UA_STATUSCODE_GOOD)
-        UA_LOG_INFO_SESSION(server->config.logger, session,
+        UA_LOG_INFO_SESSION(&server->config.logger, session,
                             "AddNodes: Node could not add the new node "
                             "to the nodestore with error code %s",
                             UA_StatusCode_name(retval));
     return retval;
 
 create_error:
-    UA_LOG_INFO_SESSION(server->config.logger, session,
+    UA_LOG_INFO_SESSION(&server->config.logger, session,
                         "AddNodes: Node could not create a node "
                         "with error code %s", UA_StatusCode_name(retval));
     UA_Nodestore_delete(server, node);
@@ -930,9 +932,9 @@ AddNode_finish(UA_Server *server, UA_Session *session, const UA_NodeId *nodeId)
         if(!type) {
             if(server->bootstrapNS0)
                 goto constructor;
-            UA_LOG_NODEID_WRAP(&node->nodeId, UA_LOG_INFO_SESSION(server->config.logger, session,
-                                                                 "AddNodes: Node type for %.*s not found",
-                                                                 (int)nodeIdStr.length, nodeIdStr.data));
+            UA_LOG_NODEID_WRAP(&node->nodeId, UA_LOG_INFO_SESSION(&server->config.logger, session,
+                                   "AddNodes: Node type for %.*s not found",
+                                   (int)nodeIdStr.length, nodeIdStr.data));
             retval = UA_STATUSCODE_BADTYPEDEFINITIONINVALID;
             goto cleanup;
         }
@@ -945,7 +947,7 @@ AddNode_finish(UA_Server *server, UA_Session *session, const UA_NodeId *nodeId)
                                                (const UA_VariableNode**)&node,
                                                (const UA_VariableTypeNode*)type);
             if(retval != UA_STATUSCODE_GOOD) {
-                UA_LOG_NODEID_WRAP(&node->nodeId, UA_LOG_INFO_SESSION(server->config.logger, session,
+                UA_LOG_NODEID_WRAP(&node->nodeId, UA_LOG_INFO_SESSION(&server->config.logger, session,
                                     "AddNodes: Using attributes for %.*s from the variable type "
                                     "failed with error code %s",
                                     (int)nodeIdStr.length, nodeIdStr.data, UA_StatusCode_name(retval)));
@@ -958,7 +960,7 @@ AddNode_finish(UA_Server *server, UA_Session *session, const UA_NodeId *nodeId)
             retval = typeCheckVariableNode(server, session, (const UA_VariableNode*)node,
                                            (const UA_VariableTypeNode*)type);
             if(retval != UA_STATUSCODE_GOOD) {
-                UA_LOG_NODEID_WRAP(&node->nodeId, UA_LOG_INFO_SESSION(server->config.logger, session,
+                UA_LOG_NODEID_WRAP(&node->nodeId, UA_LOG_INFO_SESSION(&server->config.logger, session,
                                     "AddNodes: Type-checking the variable node %.*s "
                                     "failed with error code %s",
                                     (int)nodeIdStr.length, nodeIdStr.data, UA_StatusCode_name(retval)));
@@ -971,7 +973,7 @@ AddNode_finish(UA_Server *server, UA_Session *session, const UA_NodeId *nodeId)
            node->nodeClass == UA_NODECLASS_OBJECT) {
             retval = addChildren(server, session, node, type);
             if(retval != UA_STATUSCODE_GOOD) {
-                UA_LOG_NODEID_WRAP(&node->nodeId, UA_LOG_INFO_SESSION(server->config.logger, session,
+                UA_LOG_NODEID_WRAP(&node->nodeId, UA_LOG_INFO_SESSION(&server->config.logger, session,
                                     "AddNodes: Adding child nodes of  %.*s failed with error code %s",
                                     (int)nodeIdStr.length, nodeIdStr.data, UA_StatusCode_name(retval)));
                 goto cleanup;
@@ -983,7 +985,7 @@ AddNode_finish(UA_Server *server, UA_Session *session, const UA_NodeId *nodeId)
  constructor:
     retval = callConstructors(server, session, node, type);
     if(retval != UA_STATUSCODE_GOOD) {
-        UA_LOG_NODEID_WRAP(&node->nodeId, UA_LOG_INFO_SESSION(server->config.logger, session,
+        UA_LOG_NODEID_WRAP(&node->nodeId, UA_LOG_INFO_SESSION(&server->config.logger, session,
                             "AddNodes: Calling the node constructor(s) of %.*s failed "
                             "with status code %s",
                             (int)nodeIdStr.length, nodeIdStr.data, UA_StatusCode_name(retval)));
@@ -1018,9 +1020,9 @@ Operation_addNode(UA_Server *server, UA_Session *session, void *nodeContext,
 
 void
 Service_AddNodes(UA_Server *server, UA_Session *session,
-                      const UA_AddNodesRequest *request,
-                      UA_AddNodesResponse *response) {
-    UA_LOG_DEBUG_SESSION(server->config.logger, session, "Processing AddNodesRequest");
+                 const UA_AddNodesRequest *request,
+                 UA_AddNodesResponse *response) {
+    UA_LOG_DEBUG_SESSION(&server->config.logger, session, "Processing AddNodesRequest");
 
     if(server->config.maxNodesPerNodeManagement != 0 &&
        request->nodesToAddSize > server->config.maxNodesPerNodeManagement) {
@@ -1227,7 +1229,7 @@ deleteNodeOperation(UA_Server *server, UA_Session *session, void *context,
     }
 
     if(UA_Node_hasSubTypeOrInstances(node)) {
-        UA_LOG_INFO_SESSION(server->config.logger, session,
+        UA_LOG_INFO_SESSION(&server->config.logger, session,
                             "Delete Nodes: Cannot delete a type node "
                             "with active instances or subtypes");
         UA_Nodestore_release(server, node);
@@ -1246,7 +1248,7 @@ deleteNodeOperation(UA_Server *server, UA_Session *session, void *context,
 void Service_DeleteNodes(UA_Server *server, UA_Session *session,
                          const UA_DeleteNodesRequest *request,
                          UA_DeleteNodesResponse *response) {
-    UA_LOG_DEBUG_SESSION(server->config.logger, session,
+    UA_LOG_DEBUG_SESSION(&server->config.logger, session,
                          "Processing DeleteNodesRequest");
 
     if(server->config.maxNodesPerNodeManagement != 0 &&
@@ -1354,7 +1356,7 @@ Operation_addReference(UA_Server *server, UA_Session *session, void *context,
 void Service_AddReferences(UA_Server *server, UA_Session *session,
                            const UA_AddReferencesRequest *request,
                            UA_AddReferencesResponse *response) {
-    UA_LOG_DEBUG_SESSION(server->config.logger, session,
+    UA_LOG_DEBUG_SESSION(&server->config.logger, session,
                          "Processing AddReferencesRequest");
 
     if(server->config.maxNodesPerNodeManagement != 0 &&
@@ -1427,7 +1429,7 @@ void
 Service_DeleteReferences(UA_Server *server, UA_Session *session,
                          const UA_DeleteReferencesRequest *request,
                          UA_DeleteReferencesResponse *response) {
-    UA_LOG_DEBUG_SESSION(server->config.logger, session,
+    UA_LOG_DEBUG_SESSION(&server->config.logger, session,
                          "Processing DeleteReferencesRequest");
 
     if(server->config.maxNodesPerNodeManagement != 0 &&

+ 5 - 5
src/server/ua_services_securechannel.c

@@ -25,10 +25,10 @@ Service_OpenSecureChannel(UA_Server *server, UA_SecureChannel *channel,
 
         /* Logging */
         if(response->responseHeader.serviceResult == UA_STATUSCODE_GOOD) {
-            UA_LOG_DEBUG_CHANNEL(server->config.logger, channel,
+            UA_LOG_DEBUG_CHANNEL(&server->config.logger, channel,
                                  "SecureChannel renewed");
         } else {
-            UA_LOG_DEBUG_CHANNEL(server->config.logger, channel,
+            UA_LOG_DEBUG_CHANNEL(&server->config.logger, channel,
                                  "Renewing SecureChannel failed");
         }
         return;
@@ -47,10 +47,10 @@ Service_OpenSecureChannel(UA_Server *server, UA_SecureChannel *channel,
 
     /* Logging */
     if(response->responseHeader.serviceResult == UA_STATUSCODE_GOOD) {
-        UA_LOG_INFO_CHANNEL(server->config.logger, channel,
+        UA_LOG_INFO_CHANNEL(&server->config.logger, channel,
                             "Opened SecureChannel");
     } else {
-        UA_LOG_INFO_CHANNEL(server->config.logger, channel,
+        UA_LOG_INFO_CHANNEL(&server->config.logger, channel,
                             "Opening a SecureChannel failed");
     }
 }
@@ -58,7 +58,7 @@ Service_OpenSecureChannel(UA_Server *server, UA_SecureChannel *channel,
 /* The server does not send a CloseSecureChannel response */
 void
 Service_CloseSecureChannel(UA_Server *server, UA_SecureChannel *channel) {
-    UA_LOG_INFO_CHANNEL(server->config.logger, channel, "CloseSecureChannel");
+    UA_LOG_INFO_CHANNEL(&server->config.logger, channel, "CloseSecureChannel");
     UA_SecureChannelManager_close(&server->secureChannelManager,
                                   channel->securityToken.channelId);
 }

+ 11 - 11
src/server/ua_services_session.c

@@ -69,7 +69,7 @@ Service_CreateSession(UA_Server *server, UA_SecureChannel *channel,
         return;
     }
 
-    UA_LOG_DEBUG_CHANNEL(server->config.logger, channel, "Trying to create session");
+    UA_LOG_DEBUG_CHANNEL(&server->config.logger, channel, "Trying to create session");
 
     if(channel->securityMode == UA_MESSAGESECURITYMODE_SIGN ||
        channel->securityMode == UA_MESSAGESECURITYMODE_SIGNANDENCRYPT) {
@@ -113,7 +113,7 @@ Service_CreateSession(UA_Server *server, UA_SecureChannel *channel,
     response->responseHeader.serviceResult =
         UA_SessionManager_createSession(&server->sessionManager, channel, request, &newSession);
     if(response->responseHeader.serviceResult != UA_STATUSCODE_GOOD) {
-        UA_LOG_DEBUG_CHANNEL(server->config.logger, channel,
+        UA_LOG_DEBUG_CHANNEL(&server->config.logger, channel,
                              "Processing CreateSessionRequest failed");
         return;
     }
@@ -201,7 +201,7 @@ Service_CreateSession(UA_Server *server, UA_SecureChannel *channel,
         return;
     }
 
-    UA_LOG_DEBUG_CHANNEL(server->config.logger, channel,
+    UA_LOG_DEBUG_CHANNEL(&server->config.logger, channel,
                          "Session " UA_PRINTF_GUID_FORMAT " created",
                          UA_PRINTF_GUID_DATA(newSession->sessionId.identifier.guid));
 }
@@ -252,10 +252,10 @@ void
 Service_ActivateSession(UA_Server *server, UA_SecureChannel *channel,
                         UA_Session *session, const UA_ActivateSessionRequest *request,
                         UA_ActivateSessionResponse *response) {
-    UA_LOG_DEBUG_SESSION(server->config.logger, session, "Execute ActivateSession");
+    UA_LOG_DEBUG_SESSION(&server->config.logger, session, "Execute ActivateSession");
 
     if(session->validTill < UA_DateTime_nowMonotonic()) {
-        UA_LOG_INFO_SESSION(server->config.logger, session,
+        UA_LOG_INFO_SESSION(&server->config.logger, session,
                             "ActivateSession: SecureChannel %i wants "
                             "to activate, but the session has timed out",
                             channel->securityToken.channelId);
@@ -268,7 +268,7 @@ Service_ActivateSession(UA_Server *server, UA_SecureChannel *channel,
      * to the client */
     response->responseHeader.serviceResult = checkSignature(server, channel, session, request);
     if(response->responseHeader.serviceResult != UA_STATUSCODE_GOOD) {
-        UA_LOG_INFO_SESSION(server->config.logger, session,
+        UA_LOG_INFO_SESSION(&server->config.logger, session,
                             "Signature check failed with status code %s",
                             UA_StatusCode_name(response->responseHeader.serviceResult));
         return;
@@ -329,7 +329,7 @@ Service_ActivateSession(UA_Server *server, UA_SecureChannel *channel,
                                                      &request->userIdentityToken,
                                                      &session->sessionHandle);
     if(response->responseHeader.serviceResult != UA_STATUSCODE_GOOD) {
-        UA_LOG_INFO_SESSION(server->config.logger, session,
+        UA_LOG_INFO_SESSION(&server->config.logger, session,
                             "ActivateSession: The AccessControl plugin "
                             "denied the access with the status code %s",
                             UA_StatusCode_name(response->responseHeader.serviceResult));
@@ -337,7 +337,7 @@ Service_ActivateSession(UA_Server *server, UA_SecureChannel *channel,
     }
 
     if(session->header.channel && session->header.channel != channel) {
-        UA_LOG_INFO_SESSION(server->config.logger, session,
+        UA_LOG_INFO_SESSION(&server->config.logger, session,
                             "ActivateSession: Detach from old channel");
         /* Detach the old SecureChannel and attach the new */
         UA_Session_detachFromSecureChannel(session);
@@ -355,12 +355,12 @@ Service_ActivateSession(UA_Server *server, UA_SecureChannel *channel,
     if(response->responseHeader.serviceResult != UA_STATUSCODE_GOOD) {
         UA_Session_detachFromSecureChannel(session);
         session->activated = false;
-        UA_LOG_INFO_SESSION(server->config.logger, session,
+        UA_LOG_INFO_SESSION(&server->config.logger, session,
                             "ActivateSession: Could not generate a server nonce");
         return;
     }
 
-    UA_LOG_INFO_SESSION(server->config.logger, session,
+    UA_LOG_INFO_SESSION(&server->config.logger, session,
                         "ActivateSession: Session activated");
 }
 
@@ -368,7 +368,7 @@ void
 Service_CloseSession(UA_Server *server, UA_Session *session,
                      const UA_CloseSessionRequest *request,
                      UA_CloseSessionResponse *response) {
-    UA_LOG_INFO_SESSION(server->config.logger, session, "CloseSession");
+    UA_LOG_INFO_SESSION(&server->config.logger, session, "CloseSession");
 
     /* Callback into userland access control */
     server->config.accessControl.closeSession(server, &server->config.accessControl,

+ 25 - 21
src/server/ua_services_subscription.c

@@ -36,7 +36,7 @@ setSubscriptionSettings(UA_Server *server, UA_Subscription *subscription,
     /* deregister the callback if required */
     UA_StatusCode retval = Subscription_unregisterPublishCallback(server, subscription);
     if(retval != UA_STATUSCODE_GOOD) {
-        UA_LOG_DEBUG_SESSION(server->config.logger, subscription->session,
+        UA_LOG_DEBUG_SESSION(&server->config.logger, subscription->session,
                              "Subscription %u | Could not unregister publish callback with error code %s",
                              subscription->subscriptionId, UA_StatusCode_name(retval));
         return retval;
@@ -63,7 +63,7 @@ setSubscriptionSettings(UA_Server *server, UA_Subscription *subscription,
 
     retval = Subscription_registerPublishCallback(server, subscription);
     if(retval != UA_STATUSCODE_GOOD) {
-        UA_LOG_DEBUG_SESSION(server->config.logger, subscription->session,
+        UA_LOG_DEBUG_SESSION(&server->config.logger, subscription->session,
                              "Subscription %u | Could not register publish callback with error code %s",
                              subscription->subscriptionId, UA_StatusCode_name(retval));
         return retval;
@@ -85,7 +85,7 @@ Service_CreateSubscription(UA_Server *server, UA_Session *session,
     /* Create the subscription */
     UA_Subscription *newSubscription = UA_Subscription_new(session, response->subscriptionId);
     if(!newSubscription) {
-        UA_LOG_DEBUG_SESSION(server->config.logger, session,
+        UA_LOG_DEBUG_SESSION(&server->config.logger, session,
                              "Processing CreateSubscriptionRequest failed");
         response->responseHeader.serviceResult = UA_STATUSCODE_BADOUTOFMEMORY;
         return;
@@ -112,7 +112,7 @@ Service_CreateSubscription(UA_Server *server, UA_Session *session,
     response->revisedLifetimeCount = newSubscription->lifeTimeCount;
     response->revisedMaxKeepAliveCount = newSubscription->maxKeepAliveCount;
 
-    UA_LOG_INFO_SESSION(server->config.logger, session, "Subscription %u | "
+    UA_LOG_INFO_SESSION(&server->config.logger, session, "Subscription %u | "
                         "Created the Subscription with a publishing interval of %.2f ms",
                         response->subscriptionId, newSubscription->publishingInterval);
 }
@@ -121,7 +121,7 @@ void
 Service_ModifySubscription(UA_Server *server, UA_Session *session,
                            const UA_ModifySubscriptionRequest *request,
                            UA_ModifySubscriptionResponse *response) {
-    UA_LOG_DEBUG_SESSION(server->config.logger, session, "Processing ModifySubscriptionRequest");
+    UA_LOG_DEBUG_SESSION(&server->config.logger, session, "Processing ModifySubscriptionRequest");
 
     UA_Subscription *sub = UA_Session_getSubscriptionById(session, request->subscriptionId);
     if(!sub) {
@@ -162,7 +162,7 @@ void
 Service_SetPublishingMode(UA_Server *server, UA_Session *session,
                           const UA_SetPublishingModeRequest *request,
                           UA_SetPublishingModeResponse *response) {
-    UA_LOG_DEBUG_SESSION(server->config.logger, session, "Processing SetPublishingModeRequest");
+    UA_LOG_DEBUG_SESSION(&server->config.logger, session, "Processing SetPublishingModeRequest");
     UA_Boolean publishingEnabled = request->publishingEnabled; /* request is const */
     response->responseHeader.serviceResult =
         UA_Server_processServiceOperations(server, session, (UA_ServiceOperation)Operation_SetPublishingMode,
@@ -349,7 +349,7 @@ Operation_CreateMonitoredItem(UA_Server *server, UA_Session *session, struct cre
                                        &request->requestedParameters, v.value.type);
     UA_DataValue_deleteMembers(&v);
     if(retval != UA_STATUSCODE_GOOD) {
-        UA_LOG_INFO_SESSION(server->config.logger, session,
+        UA_LOG_INFO_SESSION(&server->config.logger, session,
                             "Subscription %u | Could not create a MonitoredItem "
                             "with StatusCode %s", cmc->sub ? cmc->sub->subscriptionId : 0,
                             UA_StatusCode_name(retval));
@@ -389,7 +389,7 @@ Operation_CreateMonitoredItem(UA_Server *server, UA_Session *session, struct cre
         newMon->registered = true;
     }
 
-    UA_LOG_INFO_SESSION(server->config.logger, session,
+    UA_LOG_INFO_SESSION(&server->config.logger, session,
                         "Subscription %u | MonitoredItem %i | "
                         "Created the MonitoredItem",
                         cmc->sub ? cmc->sub->subscriptionId : 0,
@@ -409,7 +409,7 @@ void
 Service_CreateMonitoredItems(UA_Server *server, UA_Session *session,
                              const UA_CreateMonitoredItemsRequest *request,
                              UA_CreateMonitoredItemsResponse *response) {
-    UA_LOG_DEBUG_SESSION(server->config.logger, session, "Processing CreateMonitoredItemsRequest");
+    UA_LOG_DEBUG_SESSION(&server->config.logger, session, "Processing CreateMonitoredItemsRequest");
 
     if(server->config.maxMonitoredItemsPerCall != 0 &&
        request->itemsToCreateSize > server->config.maxMonitoredItemsPerCall) {
@@ -498,7 +498,7 @@ void
 Service_ModifyMonitoredItems(UA_Server *server, UA_Session *session,
                              const UA_ModifyMonitoredItemsRequest *request,
                              UA_ModifyMonitoredItemsResponse *response) {
-    UA_LOG_DEBUG_SESSION(server->config.logger, session, "Processing ModifyMonitoredItemsRequest");
+    UA_LOG_DEBUG_SESSION(&server->config.logger, session, "Processing ModifyMonitoredItemsRequest");
 
     if(server->config.maxMonitoredItemsPerCall != 0 &&
        request->itemsToModifySize > server->config.maxMonitoredItemsPerCall) {
@@ -582,7 +582,7 @@ void
 Service_SetMonitoringMode(UA_Server *server, UA_Session *session,
                           const UA_SetMonitoringModeRequest *request,
                           UA_SetMonitoringModeResponse *response) {
-    UA_LOG_DEBUG_SESSION(server->config.logger, session, "Processing SetMonitoringMode");
+    UA_LOG_DEBUG_SESSION(&server->config.logger, session, "Processing SetMonitoringMode");
 
     if(server->config.maxMonitoredItemsPerCall != 0 &&
        request->monitoredItemIdsSize > server->config.maxMonitoredItemsPerCall) {
@@ -624,7 +624,7 @@ subscriptionSendError(UA_SecureChannel *channel, UA_UInt32 requestHandle,
 void
 Service_Publish(UA_Server *server, UA_Session *session,
                 const UA_PublishRequest *request, UA_UInt32 requestId) {
-    UA_LOG_DEBUG_SESSION(server->config.logger, session, "Processing PublishRequest");
+    UA_LOG_DEBUG_SESSION(&server->config.logger, session, "Processing PublishRequest");
 
     /* Return an error if the session has no subscription */
     if(LIST_EMPTY(&session->serverSubscriptions)) {
@@ -683,7 +683,7 @@ Service_Publish(UA_Server *server, UA_Session *session,
         UA_Subscription *sub = UA_Session_getSubscriptionById(session, ack->subscriptionId);
         if(!sub) {
             response->results[i] = UA_STATUSCODE_BADSUBSCRIPTIONIDINVALID;
-            UA_LOG_DEBUG_SESSION(server->config.logger, session,
+            UA_LOG_DEBUG_SESSION(&server->config.logger, session,
                                  "Cannot process acknowledgements subscription %u",
                                  ack->subscriptionId);
             continue;
@@ -696,7 +696,7 @@ Service_Publish(UA_Server *server, UA_Session *session,
      * callback. This can also be triggered right now for a late
      * subscription. */
     UA_Session_queuePublishReq(session, entry, false);
-    UA_LOG_DEBUG_SESSION(server->config.logger, session, "Queued a publication message");
+    UA_LOG_DEBUG_SESSION(&server->config.logger, session, "Queued a publication message");
 
     /* If there are late subscriptions, the new publish request is used to
      * answer them immediately. However, a single subscription that generates
@@ -725,7 +725,7 @@ Service_Publish(UA_Server *server, UA_Session *session,
     while(immediate) {
         if(immediate->state == UA_SUBSCRIPTIONSTATE_LATE) {
             session->lastSeenSubscriptionId = immediate->subscriptionId;
-            UA_LOG_DEBUG_SESSION(server->config.logger, session,
+            UA_LOG_DEBUG_SESSION(&server->config.logger, session,
                                  "Subscription %u | Response on a late subscription",
                                  immediate->subscriptionId);
             UA_Subscription_publish(server, immediate);
@@ -750,11 +750,11 @@ Operation_DeleteSubscription(UA_Server *server, UA_Session *session, void *_,
                              UA_UInt32 *subscriptionId, UA_StatusCode *result) {
     *result = UA_Session_deleteSubscription(server, session, *subscriptionId);
     if(*result == UA_STATUSCODE_GOOD) {
-        UA_LOG_DEBUG_SESSION(server->config.logger, session,
+        UA_LOG_DEBUG_SESSION(&server->config.logger, session,
                              "Subscription %u | Subscription deleted",
                              *subscriptionId);
     } else {
-        UA_LOG_DEBUG_SESSION(server->config.logger, session,
+        UA_LOG_DEBUG_SESSION(&server->config.logger, session,
                              "Deleting Subscription with Id %u failed with error code %s",
                              *subscriptionId, UA_StatusCode_name(*result));
     }
@@ -764,7 +764,8 @@ void
 Service_DeleteSubscriptions(UA_Server *server, UA_Session *session,
                             const UA_DeleteSubscriptionsRequest *request,
                             UA_DeleteSubscriptionsResponse *response) {
-    UA_LOG_DEBUG_SESSION(server->config.logger, session, "Processing DeleteSubscriptionsRequest");
+    UA_LOG_DEBUG_SESSION(&server->config.logger, session,
+                         "Processing DeleteSubscriptionsRequest");
 
     response->responseHeader.serviceResult =
         UA_Server_processServiceOperations(server, session,
@@ -790,7 +791,8 @@ void
 Service_DeleteMonitoredItems(UA_Server *server, UA_Session *session,
                              const UA_DeleteMonitoredItemsRequest *request,
                              UA_DeleteMonitoredItemsResponse *response) {
-    UA_LOG_DEBUG_SESSION(server->config.logger, session, "Processing DeleteMonitoredItemsRequest");
+    UA_LOG_DEBUG_SESSION(&server->config.logger, session,
+                         "Processing DeleteMonitoredItemsRequest");
 
     if(server->config.maxMonitoredItemsPerCall != 0 &&
        request->monitoredItemIdsSize > server->config.maxMonitoredItemsPerCall) {
@@ -829,9 +831,11 @@ UA_Server_deleteMonitoredItem(UA_Server *server, UA_UInt32 monitoredItemId) {
 }
 
 void
-Service_Republish(UA_Server *server, UA_Session *session, const UA_RepublishRequest *request,
+Service_Republish(UA_Server *server, UA_Session *session,
+                  const UA_RepublishRequest *request,
                   UA_RepublishResponse *response) {
-    UA_LOG_DEBUG_SESSION(server->config.logger, session, "Processing RepublishRequest");
+    UA_LOG_DEBUG_SESSION(&server->config.logger, session,
+                         "Processing RepublishRequest");
 
     /* Get the subscription */
     UA_Subscription *sub = UA_Session_getSubscriptionById(session, request->subscriptionId);

+ 5 - 5
src/server/ua_session_manager.c

@@ -77,7 +77,7 @@ UA_SessionManager_cleanupTimedOut(UA_SessionManager *sm,
         /* Session has timed out? */
         if(sentry->session.validTill >= nowMonotonic)
             continue;
-        UA_LOG_INFO_SESSION(sm->server->config.logger, &sentry->session,
+        UA_LOG_INFO_SESSION(&sm->server->config.logger, &sentry->session,
                             "Session has timed out");
         sm->server->config.accessControl.closeSession(sm->server,
                                                       &sm->server->config.accessControl,
@@ -97,7 +97,7 @@ UA_SessionManager_getSessionByToken(UA_SessionManager *sm, const UA_NodeId *toke
 
         /* Session has timed out */
         if(UA_DateTime_nowMonotonic() > current->session.validTill) {
-            UA_LOG_INFO_SESSION(sm->server->config.logger, &current->session,
+            UA_LOG_INFO_SESSION(&sm->server->config.logger, &current->session,
                                 "Client tries to use a session that has timed out");
             return NULL;
         }
@@ -109,7 +109,7 @@ UA_SessionManager_getSessionByToken(UA_SessionManager *sm, const UA_NodeId *toke
     /* Session not found */
     UA_String nodeIdStr = UA_STRING_NULL;
     UA_NodeId_toString(token, &nodeIdStr);
-    UA_LOG_INFO(sm->server->config.logger, UA_LOGCATEGORY_SESSION,
+    UA_LOG_INFO(&sm->server->config.logger, UA_LOGCATEGORY_SESSION,
                 "Try to use Session with token %.*s but is not found",
                 (int)nodeIdStr.length, nodeIdStr.data);
     UA_String_deleteMembers(&nodeIdStr);
@@ -126,7 +126,7 @@ UA_SessionManager_getSessionById(UA_SessionManager *sm, const UA_NodeId *session
 
         /* Session has timed out */
         if(UA_DateTime_nowMonotonic() > current->session.validTill) {
-            UA_LOG_INFO_SESSION(sm->server->config.logger, &current->session,
+            UA_LOG_INFO_SESSION(&sm->server->config.logger, &current->session,
                                 "Client tries to use a session that has timed out");
             return NULL;
         }
@@ -138,7 +138,7 @@ UA_SessionManager_getSessionById(UA_SessionManager *sm, const UA_NodeId *session
     /* Session not found */
     UA_String sessionIdStr = UA_STRING_NULL;
     UA_NodeId_toString(sessionId, &sessionIdStr);
-    UA_LOG_INFO(sm->server->config.logger, UA_LOGCATEGORY_SESSION,
+    UA_LOG_INFO(&sm->server->config.logger, UA_LOGCATEGORY_SESSION,
                 "Try to use Session with identifier %.*s but is not found",
                 (int)sessionIdStr.length, sessionIdStr.data);
     UA_String_deleteMembers(&sessionIdStr);

+ 18 - 17
src/server/ua_subscription.c

@@ -49,7 +49,7 @@ UA_Subscription_deleteMembers(UA_Server *server, UA_Subscription *sub) {
     UA_MonitoredItem *mon, *tmp_mon;
     LIST_FOREACH_SAFE(mon, &sub->monitoredItems, listEntry, tmp_mon) {
         LIST_REMOVE(mon, listEntry);
-        UA_LOG_INFO_SESSION(server->config.logger, sub->session,
+        UA_LOG_INFO_SESSION(&server->config.logger, sub->session,
                             "Subscription %u | MonitoredItem %i | "
                             "Deleted the MonitoredItem", sub->subscriptionId,
                             mon->monitoredItemId);
@@ -68,7 +68,7 @@ UA_Subscription_deleteMembers(UA_Server *server, UA_Subscription *sub) {
     }
     UA_assert(sub->retransmissionQueueSize == 0);
 
-    UA_LOG_INFO_SESSION(server->config.logger, sub->session,
+    UA_LOG_INFO_SESSION(&server->config.logger, sub->session,
                         "Subscription %u | Deleted the Subscription",
                         sub->subscriptionId);
 }
@@ -95,7 +95,7 @@ UA_Subscription_deleteMonitoredItem(UA_Server *server, UA_Subscription *sub,
     if(!mon)
         return UA_STATUSCODE_BADMONITOREDITEMIDINVALID;
 
-    UA_LOG_INFO_SESSION(server->config.logger, sub->session,
+    UA_LOG_INFO_SESSION(&server->config.logger, sub->session,
                         "Subscription %u | MonitoredItem %i | "
                         "Delete the MonitoredItem", sub->subscriptionId,
                         mon->monitoredItemId);
@@ -148,7 +148,7 @@ UA_Subscription_addRetransmissionMessage(UA_Server *server, UA_Subscription *sub
     /* Release the oldest entry if there is not enough space */
     if(server->config.maxRetransmissionQueueSize > 0 &&
        sub->session->totalRetransmissionQueueSize >= server->config.maxRetransmissionQueueSize) {
-        UA_LOG_WARNING_SESSION(server->config.logger, sub->session, "Subscription %u | "
+        UA_LOG_WARNING_SESSION(&server->config.logger, sub->session, "Subscription %u | "
                                "Retransmission queue overflow", sub->subscriptionId);
         removeOldestRetransmissionMessage(sub->session);
     }
@@ -350,20 +350,20 @@ publishCallback(UA_Server *server, UA_Subscription *sub) {
 
 void
 UA_Subscription_publish(UA_Server *server, UA_Subscription *sub) {
-    UA_LOG_DEBUG_SESSION(server->config.logger, sub->session, "Subscription %u | "
+    UA_LOG_DEBUG_SESSION(&server->config.logger, sub->session, "Subscription %u | "
                          "Publish Callback", sub->subscriptionId);
     /* Dequeue a response */
     UA_PublishResponseEntry *pre = UA_Session_dequeuePublishReq(sub->session);
     if(pre) {
         sub->currentLifetimeCount = 0; /* Reset the LifetimeCounter */
     } else {
-        UA_LOG_DEBUG_SESSION(server->config.logger, sub->session,
+        UA_LOG_DEBUG_SESSION(&server->config.logger, sub->session,
                              "Subscription %u | The publish queue is empty",
                              sub->subscriptionId);
         ++sub->currentLifetimeCount;
 
         if(sub->currentLifetimeCount > sub->lifeTimeCount) {
-            UA_LOG_DEBUG_SESSION(server->config.logger, sub->session,
+            UA_LOG_DEBUG_SESSION(&server->config.logger, sub->session,
                                  "Subscription %u | End of lifetime "
                                  "for subscription", sub->subscriptionId);
             UA_Session_deleteSubscription(server, sub->session, sub->subscriptionId);
@@ -395,7 +395,7 @@ UA_Subscription_publish(UA_Server *server, UA_Subscription *sub) {
                 UA_Session_queuePublishReq(sub->session, pre, true); /* Re-enqueue */
             return;
         }
-        UA_LOG_DEBUG_SESSION(server->config.logger, sub->session,
+        UA_LOG_DEBUG_SESSION(&server->config.logger, sub->session,
                              "Subscription %u | Sending a KeepAlive",
                              sub->subscriptionId);
     }
@@ -403,7 +403,7 @@ UA_Subscription_publish(UA_Server *server, UA_Subscription *sub) {
     /* We want to send a response. Is the channel open? */
     UA_SecureChannel *channel = sub->session->header.channel;
     if(!channel || !pre) {
-        UA_LOG_DEBUG_SESSION(server->config.logger, sub->session,
+        UA_LOG_DEBUG_SESSION(&server->config.logger, sub->session,
                              "Subscription %u | Want to send a publish response but can't. "
                              "The subscription is late.", sub->subscriptionId);
         sub->state = UA_SUBSCRIPTIONSTATE_LATE;
@@ -420,7 +420,7 @@ UA_Subscription_publish(UA_Server *server, UA_Subscription *sub) {
         /* Allocate the retransmission entry */
         retransmission = (UA_NotificationMessageEntry*)UA_malloc(sizeof(UA_NotificationMessageEntry));
         if(!retransmission) {
-            UA_LOG_WARNING_SESSION(server->config.logger, sub->session,
+            UA_LOG_WARNING_SESSION(&server->config.logger, sub->session,
                                    "Subscription %u | Could not allocate memory for retransmission. "
                                    "The subscription is late.", sub->subscriptionId);
             sub->state = UA_SUBSCRIPTIONSTATE_LATE;
@@ -431,7 +431,7 @@ UA_Subscription_publish(UA_Server *server, UA_Subscription *sub) {
         /* Prepare the response */
         UA_StatusCode retval = prepareNotificationMessage(server, sub, message, notifications);
         if(retval != UA_STATUSCODE_GOOD) {
-            UA_LOG_WARNING_SESSION(server->config.logger, sub->session,
+            UA_LOG_WARNING_SESSION(&server->config.logger, sub->session,
                                    "Subscription %u | Could not prepare the notification message. "
                                    "The subscription is late.", sub->subscriptionId);
             UA_free(retransmission);
@@ -484,7 +484,7 @@ UA_Subscription_publish(UA_Server *server, UA_Subscription *sub) {
     }
 
     /* Send the response */
-    UA_LOG_DEBUG_SESSION(server->config.logger, sub->session,
+    UA_LOG_DEBUG_SESSION(&server->config.logger, sub->session,
                          "Subscription %u | Sending out a publish response "
                          "with %u notifications", sub->subscriptionId,
                          (UA_UInt32)notifications);
@@ -507,14 +507,15 @@ UA_Subscription_publish(UA_Server *server, UA_Subscription *sub) {
 
 UA_Boolean
 UA_Subscription_reachedPublishReqLimit(UA_Server *server,  UA_Session *session) {
-    UA_LOG_DEBUG_SESSION(server->config.logger, session, "Reached number of publish request limit");
+    UA_LOG_DEBUG_SESSION(&server->config.logger, session,
+                         "Reached number of publish request limit");
 
     /* Dequeue a response */
     UA_PublishResponseEntry *pre = UA_Session_dequeuePublishReq(session);
 
     /* Cannot publish without a response */
     if(!pre) {
-        UA_LOG_FATAL_SESSION(server->config.logger, session, "No publish requests available");
+        UA_LOG_FATAL_SESSION(&server->config.logger, session, "No publish requests available");
         return false;
     }
 
@@ -533,7 +534,7 @@ UA_Subscription_reachedPublishReqLimit(UA_Server *server,  UA_Session *session)
     response->availableSequenceNumbersSize = 0;
 
     /* Send the response */
-    UA_LOG_DEBUG_SESSION(server->config.logger, session,
+    UA_LOG_DEBUG_SESSION(&server->config.logger, session,
                          "Sending out a publish response triggered by too many publish requests");
     UA_SecureChannel_sendSymmetricMessage(session->header.channel, pre->requestId,
                      UA_MESSAGETYPE_MSG, response, &UA_TYPES[UA_TYPES_PUBLISHRESPONSE]);
@@ -547,7 +548,7 @@ UA_Subscription_reachedPublishReqLimit(UA_Server *server,  UA_Session *session)
 
 UA_StatusCode
 Subscription_registerPublishCallback(UA_Server *server, UA_Subscription *sub) {
-    UA_LOG_DEBUG_SESSION(server->config.logger, sub->session,
+    UA_LOG_DEBUG_SESSION(&server->config.logger, sub->session,
                          "Subscription %u | Register subscription "
                          "publishing callback", sub->subscriptionId);
 
@@ -566,7 +567,7 @@ Subscription_registerPublishCallback(UA_Server *server, UA_Subscription *sub) {
 
 UA_StatusCode
 Subscription_unregisterPublishCallback(UA_Server *server, UA_Subscription *sub) {
-    UA_LOG_DEBUG_SESSION(server->config.logger, sub->session, "Subscription %u | "
+    UA_LOG_DEBUG_SESSION(&server->config.logger, sub->session, "Subscription %u | "
                          "Unregister subscription publishing callback", sub->subscriptionId);
 
     if(!sub->publishCallbackIsRegistered)

+ 4 - 4
src/server/ua_subscription_datachange.c

@@ -140,7 +140,7 @@ detectValueChangeWithFilter(UA_Server *server, UA_Subscription *sub, UA_Monitore
     }
 
     if(retval != UA_STATUSCODE_GOOD) {
-        UA_LOG_WARNING_SESSION(server->config.logger, sub ? sub->session : &server->adminSession,
+        UA_LOG_WARNING_SESSION(&server->config.logger, sub ? sub->session : &server->adminSession,
                                "Subscription %u | MonitoredItem %i | "
                                "Could not encode the value the MonitoredItem with status %s",
                                sub ? sub->subscriptionId : 0, mon->monitoredItemId,
@@ -164,7 +164,7 @@ detectValueChangeWithFilter(UA_Server *server, UA_Subscription *sub, UA_Monitore
     if(valueEncoding.data == stackValueEncoding) {
         retval = UA_ByteString_copy(&valueEncoding, encoding);
         if(retval != UA_STATUSCODE_GOOD) {
-            UA_LOG_WARNING_SESSION(server->config.logger, sub ? sub->session : &server->adminSession,
+            UA_LOG_WARNING_SESSION(&server->config.logger, sub ? sub->session : &server->adminSession,
                                    "Subscription %u | MonitoredItem %i | "
                                    "Detected change, but could not allocate memory for the notification"
                                    "with status %s", sub ? sub->subscriptionId : 0,
@@ -219,7 +219,7 @@ sampleCallbackWithValue(UA_Server *server, UA_MonitoredItem *monitoredItem,
         /* Allocate a new notification */
         UA_Notification *newNotification = (UA_Notification *)UA_malloc(sizeof(UA_Notification));
         if(!newNotification) {
-            UA_LOG_WARNING_SESSION(server->config.logger, sub ? sub->session : &server->adminSession,
+            UA_LOG_WARNING_SESSION(&server->config.logger, sub ? sub->session : &server->adminSession,
                                    "Subscription %u | MonitoredItem %i | "
                                    "Item for the publishing queue could not be allocated",
                                    sub->subscriptionId, monitoredItem->monitoredItemId);
@@ -302,7 +302,7 @@ UA_MonitoredItem_sampleCallback(UA_Server *server, UA_MonitoredItem *monitoredIt
         session = sub->session;
 
     if(monitoredItem->monitoredItemType != UA_MONITOREDITEMTYPE_CHANGENOTIFY) {
-        UA_LOG_DEBUG_SESSION(server->config.logger, session, "Subscription %u | "
+        UA_LOG_DEBUG_SESSION(&server->config.logger, session, "Subscription %u | "
                              "MonitoredItem %i | Not a data change notification",
                              sub ? sub->subscriptionId : 0, monitoredItem->monitoredItemId);
         return;

+ 13 - 13
src/server/ua_subscription_events.c

@@ -54,7 +54,7 @@ UA_Event_generateEventId(UA_Server *server, UA_ByteString *generatedId) {
     generatedId->length = 16;
     generatedId->data = (UA_Byte *) UA_malloc(16 * sizeof(UA_Byte));
     if(!generatedId->data) {
-        UA_LOG_WARNING(server->config.logger, UA_LOGCATEGORY_USERLAND,
+        UA_LOG_WARNING(&server->config.logger, UA_LOGCATEGORY_USERLAND,
                        "Server unable to allocate memory for EventId data.");
         return UA_STATUSCODE_BADOUTOFMEMORY;
     }
@@ -72,7 +72,7 @@ UA_Event_generateEventId(UA_Server *server, UA_ByteString *generatedId) {
 UA_StatusCode
 UA_Server_createEvent(UA_Server *server, const UA_NodeId eventType, UA_NodeId *outNodeId) {
     if(!outNodeId) {
-        UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_USERLAND, "outNodeId cannot be NULL!");
+        UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_USERLAND, "outNodeId cannot be NULL!");
         return UA_STATUSCODE_BADINVALIDARGUMENT;
     }
 
@@ -80,7 +80,7 @@ UA_Server_createEvent(UA_Server *server, const UA_NodeId eventType, UA_NodeId *o
     UA_NodeId hasSubtypeId = UA_NODEID_NUMERIC(0, UA_NS0ID_HASSUBTYPE);
     UA_NodeId baseEventTypeId = UA_NODEID_NUMERIC(0, UA_NS0ID_BASEEVENTTYPE);
     if(!isNodeInTree(&server->config.nodestore, &eventType, &baseEventTypeId, &hasSubtypeId, 1)) {
-        UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_USERLAND,
+        UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_USERLAND,
                      "Event type must be a subtype of BaseEventType!");
         return UA_STATUSCODE_BADINVALIDARGUMENT;
     }
@@ -102,7 +102,7 @@ UA_Server_createEvent(UA_Server *server, const UA_NodeId eventType, UA_NodeId *o
                                 &newNodeId);
 
     if(retval != UA_STATUSCODE_GOOD) {
-        UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_USERLAND,
+        UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_USERLAND,
                      "Adding event failed. StatusCode %s", UA_StatusCode_name(retval));
         return retval;
     }
@@ -167,7 +167,7 @@ isValidEvent(UA_Server *server, const UA_NodeId *validEventParent, const UA_Node
     if(UA_NodeId_equal(validEventParent, &conditionTypeId) ||
        isNodeInTree(&server->config.nodestore, tEventType,
     		         &conditionTypeId, &hasSubtypeId, 1)){
-        UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_USERLAND,
+        UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_USERLAND,
                      "Alarms and Conditions are not supported yet!");
         UA_BrowsePathResult_deleteMembers(&bpr);
         UA_Variant_deleteMembers(&tOutVariant);
@@ -194,7 +194,7 @@ isValidEvent(UA_Server *server, const UA_NodeId *validEventParent, const UA_Node
 /*     } */
 
 /*     /\* where clauses were specified *\/ */
-/*     UA_LOG_WARNING(server->config.logger, UA_LOGCATEGORY_USERLAND, */
+/*     UA_LOG_WARNING(&server->config.logger, UA_LOGCATEGORY_USERLAND, */
 /*                    "Where clauses are not supported by the server."); */
 /*     *result = true; */
 /*     return UA_STATUSCODE_BADNOTSUPPORTED; */
@@ -440,14 +440,14 @@ UA_Server_triggerEvent(UA_Server *server, const UA_NodeId eventNodeId, const UA_
     UA_Boolean isInObjectsFolder = isNodeInTree(&server->config.nodestore, &origin, &objectsFolderId, parentTypeHierachy, parentTypeHierachySize);
     UA_Array_delete(parentTypeHierachy, parentTypeHierachySize, &UA_TYPES[UA_TYPES_NODEID]);
     if (!isInObjectsFolder) {
-        UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_USERLAND,
+        UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_USERLAND,
                      "Node for event must be in ObjectsFolder!");
         return UA_STATUSCODE_BADINVALIDARGUMENT;
     }
 
     UA_StatusCode retval = eventSetStandardFields(server, &eventNodeId, &origin, outEventId);
     if(retval != UA_STATUSCODE_GOOD) {
-        UA_LOG_WARNING(server->config.logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_WARNING(&server->config.logger, UA_LOGCATEGORY_SERVER,
                        "Events: Could not set the standard event fields with StatusCode %s",
                        UA_StatusCode_name(retval));
         return retval;
@@ -460,9 +460,9 @@ UA_Server_triggerEvent(UA_Server *server, const UA_NodeId eventNodeId, const UA_
     LIST_INIT(&parentHandle.nodes);
     retval = getParentsNodeIteratorCallback(origin, true, parentReferences_events[1], &parentHandle);
     if(retval != UA_STATUSCODE_GOOD) {
-        UA_LOG_WARNING(server->config.logger, UA_LOGCATEGORY_SERVER,
-                       "Events: Could not create the list of nodes listening on the event with StatusCode %s",
-                       UA_StatusCode_name(retval));
+        UA_LOG_WARNING(&server->config.logger, UA_LOGCATEGORY_SERVER,
+                       "Events: Could not create the list of nodes listening on the "
+                       "event with StatusCode %s", UA_StatusCode_name(retval));
         return retval;
     }
 
@@ -474,7 +474,7 @@ UA_Server_triggerEvent(UA_Server *server, const UA_NodeId eventNodeId, const UA_
             for(UA_MonitoredItem *monIter = node->monitoredItemQueue; monIter != NULL; monIter = monIter->next) {
                 retval = UA_Event_addEventToMonitoredItem(server, &eventNodeId, monIter);
                 if(retval != UA_STATUSCODE_GOOD) {
-                    UA_LOG_WARNING(server->config.logger, UA_LOGCATEGORY_SERVER,
+                    UA_LOG_WARNING(&server->config.logger, UA_LOGCATEGORY_SERVER,
                                    "Events: Could not add the event to a listening node with StatusCode %s",
                                    UA_StatusCode_name(retval));
                 }
@@ -491,7 +491,7 @@ UA_Server_triggerEvent(UA_Server *server, const UA_NodeId eventNodeId, const UA_
     if(deleteEventNode) {
         retval = UA_Server_deleteNode(server, eventNodeId, true);
         if (retval != UA_STATUSCODE_GOOD) {
-            UA_LOG_WARNING(server->config.logger, UA_LOGCATEGORY_SERVER,
+            UA_LOG_WARNING(&server->config.logger, UA_LOGCATEGORY_SERVER,
                            "Attempt to remove event using deleteNode failed. StatusCode %s",
                            UA_StatusCode_name(retval));
             return retval;

+ 1 - 1
src/server/ua_subscription_monitoreditem.c

@@ -162,7 +162,7 @@ UA_MonitoredItem_delete(UA_Server *server, UA_MonitoredItem *monitoredItem) {
         UA_MonitoredItem_unregisterSampleCallback(server, monitoredItem);
     } else if (monitoredItem->monitoredItemType != UA_MONITOREDITEMTYPE_EVENTNOTIFY) {
         /* TODO: Access val data.event */
-        UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER,
+        UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER,
                      "MonitoredItemTypes other than ChangeNotify or EventNotify "
                      "are not supported yet");
     }

+ 2 - 2
tests/fuzz/ua_debug_dump_pkgs_file.c

@@ -120,7 +120,7 @@ UA_debug_dump_setName_withoutChannel(UA_Server *server, UA_Connection *connectio
 
     if ((tcpMessageHeader.messageTypeAndChunkType & 0x00ffffff) == UA_MESSAGETYPE_MSG) {
         // this should not happen in normal operation
-        UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER, "Got MSG package without channel.");
+        UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER, "Got MSG package without channel.");
         return UA_STATUSCODE_BADUNEXPECTEDERROR;
     }
     return UA_STATUSCODE_GOOD;
@@ -183,7 +183,7 @@ UA_debug_dumpCompleteChunk(UA_Server *const server, UA_Connection *const connect
         cnt++;
     }
 
-    UA_LOG_INFO(server->config.logger, UA_LOGCATEGORY_SERVER,
+    UA_LOG_INFO(&server->config.logger, UA_LOGCATEGORY_SERVER,
                 "Dumping package %s", dumpOutputFile);
 
     FILE *write_ptr = fopen(dumpOutputFile, "ab");