Hi all,
I
am using open62541 1.0.1 (mainly the server part), and I am facing a
(very small) problem. I'd like to redirect all logs to my custom logger,
but when I initialize a basic server configuration a the library
produce a message (a warning about security options) directly by
UA_Log_Stdout_ logger. UA_Log_Stdout_ structure is public, but
read-only, so I can't alter it by code (at least, not in a clean way).
The best I managed to do is redirect all but the very first message by
changing the "logger" filed in configuration before creating the server:
static UA_ServerConfig cfg;
UA_ServerConfig_setDefault(&cfg);
cfg.logger = my_logger;
UA_Log_Stdout = &cfg.logger;
UA_Server *server = UA_Server_newWithConfig(&cfg);
I couldn't a way to work around this issue without modifying the library. Any ideas?
Anyway,
I suggest to add to the library a "general init" function (and a
"general deinit", too); users should call it before using any other one.
The function could accept some global configuration parameters, e.g.
the custom logger. This could also help in better managemet of system
resources (e.g. under Windows, call to WSAStartup only once; indeed it
seems to me that it gets called each time a client connection is
required in the current implementation). Another thing that the function
could do is register a custom malloc/free.