Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Review] feat(pubsub): change std_log.h into log.h, implement configurable loger for pubsub_ethernet module #3570

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

saukijan
Copy link

Description

This PR removes the use of the standard log_stdout.h from ua_pubsub_ethernet.c and implements the use of a more generalized log.h in its place.

Simmilarly to PR#3567 this is achieved by using a static UA_Logger variable, which is initially set to NULL and set during configuration when setting the transport layer by UA_PubSubTransportLayerEthernet(&config->logger)

A NULL logger is acceptable since log.h checks against it, and if it is found, no logging is done, which in principal, allows for full deactivation of the logging plugin during the configuration process.

@jpfr
Copy link
Member

jpfr commented Apr 26, 2020

Hey,

Thanks for the effort. I have a few requests from a maintainer point.

  • don’t rename to log.h This is one of several possible loggers. Log_stdout is not bad for a logger that writes to stdout.
  • don’t use static variables. Several servers can run in parallel in the same process.
    We don’t use non-constant static variables ever.
  • split essential changes and cosmetic changes in separate commits.
    This is impossible to review otherwise.

That said, using the configured logging is very welcome.

…er for pubsub_ethernet module

Signed-off-by: Dovydas Girdvainis <[email protected]>
@saukijan saukijan force-pushed the pubsub_ethenret_configurable_logger branch from 5e68c83 to 220c3c0 Compare April 28, 2020 08:22
@saukijan
Copy link
Author

saukijan commented Apr 28, 2020

Hi @jpfr ,

Thanks for your feed back! I addressed the issues you mentioned:

  • split essential changes and cosmetic changes in separate commits.
    This is impossible to review otherwise.

I removed the clang-formater changes and left in only the PR relevant changes themselves.

don’t use static variables. Several servers can run in parallel in the same process.
We don’t use non-constant static variables ever.

I think my initial comment was not really clear. This change uses a static const UA_Logger *, which allows for the pointer itself to be changed, but not it's value and the only way to change the pointer is if entire PubSub Transport Layer is rebuilt.

  • don’t rename to log.h This is one of several possible loggers. Log_stdout is not bad for a logger that writes to stdout.

I am not sure what you mean by this, log.h is the header that contains the definition for UA_Logger struct, which declares the callback footprints that all of the loggers will use, where as log_stdout.h implements said callbacks.

Correct me if I am wrong, but to me this is a typical Interface and the point of an interface is to separate concrete implementation of a functionality from the user of that functionality.

Thus if log_stdout.h header stays, there is no way to implement a configurable logger, since UA_Log_Stdout will be used regardless of what is set within UA_ServerConfig structure.

Furthermore, this change still allows for the use of UA_Log_Stdout as a logger. Instead of using a direct declaration within ua_pubsub_ethernet.c, this uses the logger that was given during PubSub Transport Layer creation (the call of UA_PubSubTransportLayerEthernet() function) and by default this is set to UA_Log_Stdout by functions like UA_ServerConfig_setDefault(UA_ServerConfig *config)

@saukijan saukijan changed the title [WIP] feat(pubsub): change std_log.h into log.h, implement configurable loger for pubsub_ethernet module [Review] feat(pubsub): change std_log.h into log.h, implement configurable loger for pubsub_ethernet module Apr 28, 2020
@saukijan
Copy link
Author

@jpfr, this PR is ready for review

@saukijan saukijan changed the title [Review] feat(pubsub): change std_log.h into log.h, implement configurable loger for pubsub_ethernet module [WIP] feat(pubsub): change std_log.h into log.h, implement configurable loger for pubsub_ethernet module May 22, 2020
@saukijan
Copy link
Author

Ill re-add the log_stdout.h and try to do something similar to PR #3567 and contexts

@saukijan
Copy link
Author

Hey @jpfr, I moved const UA_Logger * logger to UA_PubSubConnectionConfig struct, however I am unsure who sets it and how TransportLayerEthernet_addChannel(UA_PubSubConnectionConfig *connectionConfig) is called with UA_PubSubConnectionConfig parameter.

@jpfr
Copy link
Member

jpfr commented Aug 28, 2020

The core of the change looks good.
There are some artifacts in the PR that are not needed.

  • Changes to submodules
  • UA_Boolean configurationFrozen;

Can you clean up the PR and rebase? Then we can merge.

@saukijan
Copy link
Author

sure thing, I'll commit the fixes next week

@saukijan
Copy link
Author

sorry for the long delay, applied the changes, ready for review

@saukijan saukijan changed the title [WIP] feat(pubsub): change std_log.h into log.h, implement configurable loger for pubsub_ethernet module [Review] feat(pubsub): change std_log.h into log.h, implement configurable loger for pubsub_ethernet module Sep 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants