Commit 8b3ee9d
committed
fix(opcua,#386): replace std::cerr traces with RCLCPP_DEBUG_STREAM (bburda review)
Per bburda review on PR #387: env-var-gated ``std::cerr`` (Copilot fix
round) was the wrong observability primitive. It bypasses the gateway's
log-level controls (``--log-level opcua.client:=debug``,
``RCUTILS_LOGGING_USE_STDOUT``, /rosout aggregation) and floods raw
container stderr instead of integrating with the rest of the plugin's
log_info / log_warn plumbing.
All 18 trace sites switched to ``RCLCPP_DEBUG_STREAM`` against named
loggers - ``opcua.client`` (trampoline, add_event_monitored_item,
createEvent result, call_method status), ``opcua.poller`` (on_event,
captured EventId hex, state-machine inputs, dispatching action), and
``opcua.plugin`` (acknowledge_fault / confirm_fault EventId hex).
Three places kept a manual pre-gate via per-logger ``debug_enabled()``
helpers because the trace builds an ``std::ostringstream`` whose
construction RCLCPP_DEBUG_STREAM does NOT short-circuit (the macro
constructs a stringstream unconditionally and only the underlying
RCUTILS log emission is level-gated). Pre-gating keeps the per-event
formatting cost off the hot path at INFO. The ``Level`` enum class is
compared via ``static_cast<int>`` because it has no defined ``operator<=``.
Removed the ``opcua_trace_enabled()`` env-var helpers and their
duplicated definitions across all three .cpp files; the env-var
``ROS2_MEDKIT_OPCUA_TRACE`` is replaced by the standard ROS log-level
flow. Operators now toggle traces with:
ros2 launch ... --log-level opcua.client:=debug
ros2 launch ... --log-level opcua.poller:=debug
ros2 launch ... --log-level opcua.plugin:=debug
The ``[opcua_poller WARN] ConditionRefresh rejected`` fallback (when
PollerConfig.log_warn is not wired) now goes through ``RCLCPP_WARN``
instead of raw stderr, again routing the message through /rosout.
CMakeLists.txt: ``test_opcua_client`` gains ``rclcpp`` as a target
dependency because ``opcua_client.cpp`` now includes
``rclcpp/logging.hpp``. The unit tests do not call ``rclcpp::init`` so
this is link-only.
Local verify: 27/27 test_opcua_client + 27/27 test_alarm_state_machine
+ 32/32 test_node_map.1 parent a2a2faa commit 8b3ee9d
4 files changed
Lines changed: 95 additions & 86 deletions
File tree
- src/ros2_medkit_plugins/ros2_medkit_opcua
- src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
197 | 201 | | |
198 | 202 | | |
| 203 | + | |
199 | 204 | | |
200 | 205 | | |
201 | 206 | | |
| |||
Lines changed: 40 additions & 37 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | 19 | | |
21 | 20 | | |
22 | | - | |
| 21 | + | |
23 | 22 | | |
24 | 23 | | |
25 | 24 | | |
26 | 25 | | |
27 | 26 | | |
28 | 27 | | |
29 | 28 | | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
45 | 50 | | |
| 51 | + | |
46 | 52 | | |
47 | 53 | | |
48 | 54 | | |
| |||
614 | 620 | | |
615 | 621 | | |
616 | 622 | | |
617 | | - | |
618 | | - | |
619 | | - | |
620 | | - | |
| 623 | + | |
| 624 | + | |
621 | 625 | | |
622 | 626 | | |
623 | | - | |
624 | | - | |
625 | | - | |
| 627 | + | |
626 | 628 | | |
627 | 629 | | |
628 | 630 | | |
| |||
729 | 731 | | |
730 | 732 | | |
731 | 733 | | |
732 | | - | |
733 | | - | |
734 | | - | |
735 | | - | |
736 | | - | |
737 | | - | |
738 | | - | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
739 | 741 | | |
740 | 742 | | |
741 | 743 | | |
| |||
752 | 754 | | |
753 | 755 | | |
754 | 756 | | |
755 | | - | |
756 | | - | |
757 | | - | |
758 | | - | |
| 757 | + | |
| 758 | + | |
759 | 759 | | |
760 | 760 | | |
761 | 761 | | |
| |||
864 | 864 | | |
865 | 865 | | |
866 | 866 | | |
867 | | - | |
868 | | - | |
869 | | - | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
870 | 871 | | |
871 | | - | |
| 872 | + | |
872 | 873 | | |
873 | | - | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
874 | 877 | | |
875 | 878 | | |
876 | 879 | | |
| |||
Lines changed: 18 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
923 | 924 | | |
924 | 925 | | |
925 | 926 | | |
926 | | - | |
| 927 | + | |
| 928 | + | |
927 | 929 | | |
928 | | - | |
929 | | - | |
930 | 930 | | |
931 | 931 | | |
932 | 932 | | |
933 | | - | |
| 933 | + | |
934 | 934 | | |
935 | | - | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
936 | 938 | | |
937 | 939 | | |
938 | 940 | | |
| |||
Lines changed: 32 additions & 33 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
22 | 20 | | |
| 21 | + | |
23 | 22 | | |
24 | 23 | | |
25 | 24 | | |
26 | 25 | | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
40 | 39 | | |
41 | 40 | | |
42 | 41 | | |
| |||
299 | 298 | | |
300 | 299 | | |
301 | 300 | | |
302 | | - | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
303 | 305 | | |
304 | 306 | | |
305 | 307 | | |
| |||
314 | 316 | | |
315 | 317 | | |
316 | 318 | | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
321 | 322 | | |
322 | 323 | | |
323 | 324 | | |
| |||
402 | 403 | | |
403 | 404 | | |
404 | 405 | | |
405 | | - | |
406 | | - | |
| 406 | + | |
| 407 | + | |
407 | 408 | | |
408 | 409 | | |
409 | 410 | | |
410 | 411 | | |
411 | | - | |
| 412 | + | |
412 | 413 | | |
413 | | - | |
| 414 | + | |
| 415 | + | |
414 | 416 | | |
415 | | - | |
416 | | - | |
| 417 | + | |
| 418 | + | |
417 | 419 | | |
418 | 420 | | |
419 | 421 | | |
420 | | - | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | | - | |
426 | | - | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
427 | 428 | | |
428 | 429 | | |
429 | 430 | | |
| |||
456 | 457 | | |
457 | 458 | | |
458 | 459 | | |
459 | | - | |
460 | | - | |
461 | | - | |
462 | | - | |
| 460 | + | |
| 461 | + | |
463 | 462 | | |
464 | 463 | | |
465 | 464 | | |
| |||
0 commit comments