eclipse-iceoryx / iceoryx2

Eclipse iceoryx2™ - true zero-copy inter-process-communication in pure Rust
https://iceoryx.io
Apache License 2.0
1.03k stars 40 forks source link

Add `-l` / `--log-level` option to all examples #396

Open elfenpiff opened 1 month ago

elfenpiff commented 1 month ago

(Code) Example Of Cumbersome API

Sometimes, a bug occurs in an example, or the example is the starting point of a user project, and then something goes wrong. It would be helpful if the user could easily increase the log level by adding a command-line option.

This should be implemented as efficiently as possible (from a lines of code view). This means that the argument parsing should only be one or two lines of additional code in the examples. The logic shall be stored in an external library that does all the logic. This logic shall be available for all examples in all languages.

elBoberido commented 1 month ago

@elfenpiff I just remember that I introduced a log_level_from_env_or(LogLevel) function in iceoryx1.

We could also do this for iceoryx2 and just set an IOX2_LOG_LEVEL=trace environment variable in out bashrc. With this, we would still have the detailed log by default and the examples would have a less noisy by default.

It would also require less code to be added to the examples