Skip to content

Conversation

@benjirewis
Copy link
Member

@benjirewis benjirewis commented Dec 3, 2025

RSDK-12690

Reorganizes/names Subloggers such that the following list of logger name prefixes can be used to check if a logger name is "diagnostic" in app:

  • "rdk.config"
  • "rdk.framesystem"
  • "rdk.ftdc"
  • "rdk.job_manager"
  • "rdk.networking"
  • "rdk.network-checks"

The changes in this PR are mostly related to creating a new "rdk.config" logger to move some diagnostic config-related logs out of the user-facing "rdk" logger.

The actual message of all logs remains unchanged and no new logs have been added.

@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Dec 3, 2025
@benjirewis
Copy link
Member Author

benjirewis commented Dec 3, 2025

Let's say I start viam-server with a fake motor, a single module, and a modular generic component and then stop viam-server. The logs used to look as follows:

2025-12-05T20:42:01.966Z        INFO    rdk     config/logging_level.go:41      Log level initialized: info
2025-12-05T20:42:01.969Z        INFO    rdk.networking.app_connection   grpc/app_conn.go:55     attempting to establish initial global connection to app        {"url":"localhost:8080","start_time":"2025-12-05 15:42:01.969199 -0500 EST m=+0.207344126","deadline":"2025-12-05 15:42:02.969196 -0500 EST m=+1.207340543"}
2025-12-05T20:42:01.976Z        INFO    rdk.networking.signaling_connection     grpc/app_conn.go:55     attempting to establish initial global connection to app        {"url":"localhost:8081","start_time":"2025-12-05 15:42:01.976566 -0500 EST m=+0.214710334","deadline":"2025-12-05 15:42:02.976565 -0500 EST m=+1.214709376"}
2025-12-05T20:42:01.977Z        INFO    rdk     server/entrypoint.go:107        Viam RDK built from source; version unknown
2025-12-05T20:42:01.977Z        INFO    rdk     server/entrypoint.go:92 Starting viam-server with following environment variables       {"HOME":"/Users/benjirewis"}
2025-12-05T20:42:01.977Z        INFO    rdk     server/entrypoint.go:277        Getting up-to-date config from cloud...
2025-12-05T20:42:01.977Z        INFO    rdk.network-checks      networkcheck/network-check.go:33        Starting network checks
2025-12-05T20:42:01.983Z        INFO    rdk     config/platform.go:181  platform tags   {"tags":"os_version:15"}
2025-12-05T20:42:02.018Z        INFO    rdk     config/reader.go:400    Using cloud config, but BindAddress is specified in local config (:8082) and not cloud config (default = localhost:8080). Using local's.
2025-12-05T20:42:02.018Z        INFO    rdk     server/entrypoint.go:521        Processing initial robot config...
2025-12-05T20:42:02.018Z        INFO    rdk     server/entrypoint.go:536        Agent does not handle checking needs restart functionality; will handle in server
2025-12-05T20:42:02.019Z        INFO    rdk.framesystem framesystem/framesystem.go:214  Reconfigured. Known components: map[]
2025-12-05T20:42:02.023Z        INFO    rdk     server/entrypoint.go:606        Robot created with minimal config       {"time_to_create":"4.820958ms"}
2025-12-05T20:42:02.023Z        INFO    rdk.package_manager     packages/deferred_package_manager.go:148        cloud package manager created asyncronously
2025-12-05T20:42:02.023Z        INFO    rdk     server/entrypoint.go:640        Config watcher started
2025-12-05T20:42:02.023Z        WARN    rdk.modmanager.first_run        config/module.go:300    failed to parse meta.json, skipping first run   {"error":"local non-tarball: did not search for meta.json","module":"simple2"}
2025-12-05T20:42:02.024Z        INFO    rdk     impl/local_robot.go:1591        (Re)configuring robot
2025-12-05T20:42:02.024Z        INFO    rdk.modmanager.simple2  modmanager/manager.go:274       Now adding module       {"module":"simple2"}
2025-12-05T20:42:02.024Z        INFO    rdk.modmanager.simple2  modmanager/module.go:254        Starting module in working directory    {"module":"simple2","dir":"/Users/benjirewis/Code/Viam/rdk/examples/customresources/demos/simplemodule"}
2025-12-05T20:42:02.026Z        WARN    rdk.modmanager.simple2  modmanager/module.go:477        Cannot start a system statser for module with pid       {"pid":57203,"err":"could not read \"/proc\": stat /proc: no such file or directory"}
2025-12-05T20:42:02.026Z        INFO    rdk.modmanager.simple2  modmanager/module.go:301        Starting up module      {"module":"simple2","tcp_mode":false}
2025-12-05T20:42:02.026Z        INFO    rdk.modmanager.simple2  utils/env.go:179        Starting module with following Viam environment variables       {"environment":["VIAM_API_KEY_ID=643cbf5d-b805-4cbe-a6e5-e8fe08d6f1a3","VIAM_MODULE_ROOT=/Users/benjirewis/Code/Viam/rdk/examples/customresources/demos/simplemodule","VIAM_PRIMARY_ORG_ID=4b786aa9-13d7-4e39-9169-241749f50afe","VIAM_MACHINE_PART_ID=146f1d0f-4452-4eb1-b333-80c393257714","VIAM_API_KEY=XXXXXXXXXX","VIAM_HOME=/Users/benjirewis/.viam","VIAM_MODULE_DATA=/Users/benjirewis/.viam/module-data/146f1d0f-4452-4eb1-b333-80c393257714/simple2","VIAM_MODULE_NAME=simple2","VIAM_LOCATION_ID=660rm6d3f8","VIAM_MACHINE_FQDN=new-main.660rm6d3f8.viam.cloud","VIAM_MACHINE_ID=d88f09aa-2398-48b6-b52a-1a6b7fc98111"]}
2025-12-05T20:42:02.027Z        INFO    rdk.networking  rpc/server.go:700       Running external signaling      {"signaling_address":"localhost:8081","for_hosts":["new-main.660rm6d3f8.viam.cloud"]}
2025-12-05T20:42:02.028Z        INFO    rdk.networking  rpc/server.go:732       Running internal signaling      {"signaling_address":"127.0.0.1:55587","for_hosts":["new-main.660rm6d3f8.viam.cloud","new-main.660rm6d3f8.local.viam.cloud","new-main.660rm6d3f8.local.viam.cloud:8082"]}
2025-12-05T20:42:02.034Z        INFO    rdk     web/web.go:528  serving {"url":"http://new-main.660rm6d3f8.local.viam.cloud:8082","alt_url":"http://0.0.0.0:8082"}
2025-12-05T20:42:02.257Z        INFO    rdk.network-checks.dns  networkcheck/network-check-types.go:193 3/3 dns connection and 4/4 dns resolution tests succeeded       {"dns_tests":"[{test_type: connection, dns_server: 1.1.1.1:53, connect_time_ms: 0, query_time_ms: 23, response_size: 124},{test_type: connection, dns_server: 8.8.8.8:53, connect_time_ms: 0, query_time_ms: 28, response_size: 44},{test_type: connection, dns_server: 208.67.222.222:53, connect_time_ms: 0, query_time_ms: 25, response_size: 44},{test_type: resolution, hostname: cloudflare.com, resolution_time_ms: 15, resolved_ips: 2606:4700::6810:85e5, 2606:4700::6810:84e5, 104.16.133.229, 104.16.132.229},{test_type: resolution, hostname: google.com, resolution_time_ms: 16, resolved_ips: 2607:f8b0:4006:821::200e, 142.251.40.206},{test_type: resolution, hostname: github.com, resolution_time_ms: 18, resolved_ips: 140.82.114.4},{test_type: resolution, hostname: viam.com, resolution_time_ms: 151, resolved_ips: 64.68.202.16}]"}
2025-12-05T20:42:03.343Z        INFO    rdk.network-checks.udp  networkcheck/network-check-types.go:282 7/7 udp STUN tests succeeded    {"udp_tests":"[{stun_server_url: global.stun.twilio.com:3478, stun_server_addr: 34.203.251.195:3478, bind_response_addr: 73.47.51.100:61607, time_to_bind_response_ms: 27},{stun_server_url: turn.viam.com:443, stun_server_addr: 34.123.161.254:443, bind_response_addr: 73.47.51.100:61607, time_to_bind_response_ms: 56},{stun_server_url: turn.viam.com:3478, stun_server_addr: 34.123.161.254:3478, bind_response_addr: 73.47.51.100:61607, time_to_bind_response_ms: 57},{stun_server_url: stun.l.google.com:3478, stun_server_addr: 74.125.250.129:3478, bind_response_addr: 73.47.51.100:61607, time_to_bind_response_ms: 27},{stun_server_url: stun.l.google.com:19302, stun_server_addr: 74.125.250.129:19302, bind_response_addr: 73.47.51.100:61607, time_to_bind_response_ms: 26},{stun_server_url: stun.sipgate.net:3478, stun_server_addr: 15.197.250.192:3478, bind_response_addr: 73.47.51.100:61607, time_to_bind_response_ms: 241},{stun_server_url: stun.sipgate.net:3479, stun_server_addr: 15.197.250.192:3479, bind_response_addr: 73.47.51.100:61607, time_to_bind_response_ms: 240}]","udp_source_address":"[::]:61607"}
2025-12-05T20:42:03.589Z        INFO    rdk.network-checks.tcp  networkcheck/network-check-types.go:282 2/2 tcp STUN tests succeeded    {"tcp_tests":"[{stun_server_url: turn.viam.com:443, tcp_source_address: 192.168.0.96:55593, stun_server_addr: 34.123.161.254:443, bind_response_addr: 73.47.51.100:55593, time_to_bind_response_ms: 58},{stun_server_url: turn.viam.com:3478, tcp_source_address: 192.168.0.96:55594, stun_server_addr: 34.123.161.254:3478, bind_response_addr: 73.47.51.100:55594, time_to_bind_response_ms: 67}]"}
2025-12-05T20:42:04.024Z        WARN    rdk.modmanager.simple2  utils/ticker.go:22      Waiting for module to complete startup and registration {"module":"simple2","time_elapsed":"2s"}
2025-12-05T20:42:04.752Z        INFO    rdk.modmanager.simple2.StdOut   pexec/managed_process.go:444
\_ 2025-12-05T20:42:04.752Z     INFO    simple2 module/runtime.go:19    module version: v0.104.1-0.20251204235030-e62aec26af1f, go version: go1.25.1
2025-12-05T20:42:04.753Z        INFO    rdk.modmanager.simple2.StdOut   pexec/managed_process.go:444
\_ 2025-12-05T20:42:04.753Z     INFO    simple2 module/module.go:254    server listening at /var/folders/gp/_3v6m84n1hxg26d8pxt4ltrw0000gn/T/viam-module-2603009231/simple2-fWyoz.sock
2025-12-05T20:42:04.829Z        INFO    rdk.modmanager.simple2  modmanager/module.go:123        Waiting for module to respond to ready request  {"module":"simple2"}
2025-12-05T20:42:04.835Z        INFO    rdk.modmanager.simple2.StdOut   pexec/managed_process.go:444
\_ 2025-12-05T20:42:04.835Z     INFO    simple2 client/client.go:522    A WebRTC connection was made to the robot. Reconnects will disallow direct gRPC connections.
2025-12-05T20:42:04.835Z        INFO    rdk.modmanager.simple2.StdOut   pexec/managed_process.go:444
\_ 2025-12-05T20:42:04.835Z     INFO    simple2 client/client.go:493    successfully (re)connected to remote at address {"address":"unix:///var/folders/gp/_3v6m84n1hxg26d8pxt4ltrw0000gn/T/viam-module-2603009231/parent.sock"}
2025-12-05T20:42:04.839Z        INFO    rdk.modmanager.simple2  modmanager/module.go:396        Registering component API and model from module {"module":"simple2","API":"rdk:component:generic","model":"acme:demo:mycounter"}
2025-12-05T20:42:04.839Z        INFO    rdk.modmanager.simple2  modmanager/manager.go:398       Module successfully added       {"module":"simple2"}
2025-12-05T20:42:04.839Z        INFO    rdk.modmanager  modmanager/manager.go:294       Modules successfully added      {"modules":["simple2"]}
2025-12-05T20:42:04.840Z        INFO    rdk.resource_manager    impl/resource_manager.go:782    Now configuring resource        {"resource":"rdk:component:generic/c","model":"acme:demo:mycounter"}
2025-12-05T20:42:04.840Z        INFO    rdk.resource_manager    impl/resource_manager.go:782    Now configuring resource        {"resource":"rdk:component:motor/foo","model":"rdk:builtin:fake"}
2025-12-05T20:42:04.840Z        INFO    rdk.resource_manager.rdk:component:motor/foo    fake/motor.go:129       board not provided, using a fake board
2025-12-05T20:42:04.840Z        INFO    rdk.resource_manager.rdk:component:motor/foo    fake/motor.go:152       Max RPM not provided to a fake motor, defaulting to 100
2025-12-05T20:42:04.840Z        INFO    rdk.resource_manager    impl/resource_manager.go:833    Successfully configured resource        {"resource":"rdk:component:motor/foo","model":"rdk:builtin:fake"}
2025-12-05T20:42:04.840Z        INFO    rdk.modmanager.simple2  modmanager/manager.go:554       Adding resource to module       {"resource":"c","module":"simple2"}
2025-12-05T20:42:04.841Z        INFO    rdk.resource_manager    impl/resource_manager.go:833    Successfully configured resource        {"resource":"rdk:component:generic/c","model":"acme:demo:mycounter"}
2025-12-05T20:42:04.841Z        INFO    rdk.framesystem framesystem/framesystem.go:214  Reconfigured. Known components: map[c:0x140011089c0 foo:0x140010ec3f0]
2025-12-05T20:42:04.841Z        INFO    rdk     impl/local_robot.go:1647        Robot (re)configured
2025-12-05T20:42:04.841Z        INFO    rdk     server/entrypoint.go:356        Robot reconfigured with full config     {"time_to_reconfigure":"2.817748833s"}
2025-12-05T20:42:12.638Z      INFO    rdk     web/web.go:196  Viam RDK shutting down
2025-12-05T20:42:12.638Z        INFO    rdk.networking  rpc/server.go:937       stopping
2025-12-05T20:42:12.638Z        INFO    rdk.networking  rpc/wrtc_server.go:127  waiting for handlers to complete
2025-12-05T20:42:12.638Z        INFO    rdk.networking  rpc/wrtc_server.go:132  handlers complete
2025-12-05T20:42:12.638Z        INFO    rdk.networking  rpc/wrtc_server.go:133  closing lingering peer connections
2025-12-05T20:42:12.638Z        INFO    rdk.networking  rpc/wrtc_server.go:151  lingering peer connections closed
2025-12-05T20:42:12.639Z        INFO    rdk.networking  rpc/server.go:969       stopped cleanly
2025-12-05T20:42:12.640Z        INFO    rdk.resource_manager    impl/resource_manager.go:558    Now removing resource   {"resource":"rdk:component:motor/foo"}
2025-12-05T20:42:12.640Z        INFO    rdk.resource_manager    impl/resource_manager.go:558    Now removing resource   {"resource":"rdk:component:generic/c"}
2025-12-05T20:42:12.640Z        INFO    rdk.modmanager.simple2  modmanager/manager.go:660       Removing resource for module    {"resource":"rdk:component:generic/c","module":"simple2"}
2025-12-05T20:42:12.641Z        INFO    rdk.resource_manager    impl/resource_manager.go:558    Now removing resource   {"resource":"rdk-internal:service:frame_system/builtin"}
2025-12-05T20:42:12.641Z        INFO    rdk.resource_manager    impl/resource_manager.go:558    Now removing resource   {"resource":"rdk-internal:service:packagemanager/deferred-manager"}
2025-12-05T20:42:12.641Z        INFO    rdk.resource_manager    impl/resource_manager.go:558    Now removing resource   {"resource":"rdk-internal:service:cloud_connection/builtin"}
2025-12-05T20:42:12.641Z        INFO    rdk.modmanager.simple2  modmanager/module.go:342        Stopping module: simple2 process
2025-12-05T20:42:12.641Z        INFO    rdk.modmanager.simple2.simple2  pexec/managed_process_unix.go:100       stopping process 57203 with signal terminated
2025-12-05T20:42:12.642Z        INFO    simple2 module/module.go:278    Shutting down gracefully.       {"log_ts":"2025-12-05T20:42:12.641Z"}
2025-12-05T20:42:12.647Z        WARN    rdk.ftdc        ftdc/ftdc.go:210        Did not find statser to remove  {"name":"proc.modules.simple2"}
2025-12-05T20:42:12.648Z        INFO    rdk.modmanager.simple2  modmanager/manager.go:537       Module successfully closed      {"module":"simple2"}
2025-12-05T20:42:12.648Z        INFO    rdk.job_manager jobmanager/jobmanager.go:169    JobManager is shutting down.

With this PR, they now look like (just drawing attention to the new "rdk.config" logger):

2025-12-05T20:35:35.548Z        INFO    rdk.config      config/logging_level.go:45      Log level initialized: info
2025-12-05T20:35:35.550Z        INFO    rdk.networking.app_connection   grpc/app_conn.go:55     attempting to establish initial global connection to app        {"url":"localhost:8080","start_time":"2025-12-05 15:35:35.550235 -0500 EST m=+0.263935209","deadline":"2025-12-05 15:35:36.550231 -0500 EST m=+1.263931501"}
2025-12-05T20:35:35.554Z        INFO    rdk.networking.signaling_connection     grpc/app_conn.go:55     attempting to establish initial global connection to app        {"url":"localhost:8081","start_time":"2025-12-05 15:35:35.554293 -0500 EST m=+0.267993334","deadline":"2025-12-05 15:35:36.554292 -0500 EST m=+1.267992501"}
2025-12-05T20:35:35.554Z        INFO    rdk     server/entrypoint.go:107        Viam RDK built from source; version unknown
2025-12-05T20:35:35.555Z        INFO    rdk     server/entrypoint.go:92 Starting viam-server with following environment variables       {"HOME":"/Users/benjirewis"}
2025-12-05T20:35:35.555Z        INFO    rdk.config      server/entrypoint.go:291        Getting up-to-date config from cloud...
2025-12-05T20:35:35.555Z        INFO    rdk.network-checks      networkcheck/network-check.go:33        Starting network checks
2025-12-05T20:35:35.562Z        INFO    rdk.config      config/platform.go:181  platform tags   {"tags":"os_version:15"}
2025-12-05T20:35:35.608Z        INFO    rdk.config      config/reader.go:400    Using cloud config, but BindAddress is specified in local config (:8082) and not cloud config (default = localhost:8080). Using local's.
2025-12-05T20:35:35.608Z        INFO    rdk.config      server/entrypoint.go:535        Processing initial robot config...
2025-12-05T20:35:35.608Z        INFO    rdk.networking  server/entrypoint.go:550        Agent does not handle checking needs restart functionality; will handle in server
2025-12-05T20:35:35.609Z        INFO    rdk.framesystem framesystem/framesystem.go:214  Reconfigured. Known components: map[]
2025-12-05T20:35:35.610Z        INFO    rdk.package_manager     packages/deferred_package_manager.go:148        cloud package manager created asyncronously
2025-12-05T20:35:35.611Z        INFO    rdk.config      server/entrypoint.go:620        Robot created with minimal config       {"time_to_create":"2.767083ms"}
2025-12-05T20:35:35.611Z        INFO    rdk.config      server/entrypoint.go:654        Config watcher started
2025-12-05T20:35:35.611Z        WARN    rdk.modmanager.first_run        config/module.go:300    failed to parse meta.json, skipping first run   {"error":"local non-tarball: did not search for meta.json","module":"simple2"}
2025-12-05T20:35:35.611Z        INFO    rdk     impl/local_robot.go:1591        (Re)configuring robot
2025-12-05T20:35:35.611Z        INFO    rdk.modmanager.simple2  modmanager/manager.go:274       Now adding module       {"module":"simple2"}
2025-12-05T20:35:35.612Z        INFO    rdk.modmanager.simple2  modmanager/module.go:254        Starting module in working directory    {"module":"simple2","dir":"/Users/benjirewis/Code/Viam/rdk/examples/customresources/demos/simplemodule"}
2025-12-05T20:35:35.613Z        WARN    rdk.modmanager.simple2  modmanager/module.go:477        Cannot start a system statser for module with pid       {"pid":56381,"err":"could not read \"/proc\": stat /proc: no such file or directory"}
2025-12-05T20:35:35.614Z        INFO    rdk.modmanager.simple2  modmanager/module.go:301        Starting up module      {"module":"simple2","tcp_mode":false}
2025-12-05T20:35:35.614Z        INFO    rdk.networking  rpc/server.go:700       Running external signaling      {"signaling_address":"localhost:8081","for_hosts":["new-main.660rm6d3f8.viam.cloud"]}
2025-12-05T20:35:35.614Z        INFO    rdk.modmanager.simple2  utils/env.go:179        Starting module with following Viam environment variables       {"environment":["VIAM_HOME=/Users/benjirewis/.viam","VIAM_MACHINE_PART_ID=146f1d0f-4452-4eb1-b333-80c393257714","VIAM_API_KEY_ID=643cbf5d-b805-4cbe-a6e5-e8fe08d6f1a3","VIAM_API_KEY=XXXXXXXXXX","VIAM_LOCATION_ID=660rm6d3f8","VIAM_MACHINE_FQDN=new-main.660rm6d3f8.viam.cloud","VIAM_MODULE_DATA=/Users/benjirewis/.viam/module-data/146f1d0f-4452-4eb1-b333-80c393257714/simple2","VIAM_MODULE_NAME=simple2","VIAM_MODULE_ROOT=/Users/benjirewis/Code/Viam/rdk/examples/customresources/demos/simplemodule","VIAM_PRIMARY_ORG_ID=4b786aa9-13d7-4e39-9169-241749f50afe","VIAM_MACHINE_ID=d88f09aa-2398-48b6-b52a-1a6b7fc98111"]}
2025-12-05T20:35:35.615Z        INFO    rdk.networking  rpc/server.go:732       Running internal signaling      {"signaling_address":"127.0.0.1:55069","for_hosts":["new-main.660rm6d3f8.viam.cloud","new-main.660rm6d3f8.local.viam.cloud","new-main.660rm6d3f8.local.viam.cloud:8082"]}
2025-12-05T20:35:35.617Z        INFO    rdk     web/web.go:528  serving {"url":"http://new-main.660rm6d3f8.local.viam.cloud:8082","alt_url":"http://0.0.0.0:8082"}
2025-12-05T20:35:35.826Z        INFO    rdk.network-checks.dns  networkcheck/network-check-types.go:193 3/3 dns connection and 4/4 dns resolution tests succeeded       {"dns_tests":"[{test_type: connection, dns_server: 1.1.1.1:53, connect_time_ms: 0, query_time_ms: 23, response_size: 44},{test_type: connection, dns_server: 8.8.8.8:53, connect_time_ms: 0, query_time_ms: 27, response_size: 44},{test_type: connection, dns_server: 208.67.222.222:53, connect_time_ms: 0, query_time_ms: 30, response_size: 44},{test_type: resolution, hostname: cloudflare.com, resolution_time_ms: 20, resolved_ips: 2606:4700::6810:84e5, 2606:4700::6810:85e5, 104.16.133.229, 104.16.132.229},{test_type: resolution, hostname: google.com, resolution_time_ms: 18, resolved_ips: 2607:f8b0:4006:816::200e, 142.251.40.206},{test_type: resolution, hostname: github.com, resolution_time_ms: 19, resolved_ips: 140.82.114.3},{test_type: resolution, hostname: viam.com, resolution_time_ms: 131, resolved_ips: 64.68.202.16}]"}
2025-12-05T20:35:36.901Z        INFO    rdk.networking  rpc/wrtc_base_channel.go:136    Diagnostic data for successful webrtc connection attempt        {"conn_id":"PeerConnection-1764966936739715000","conn_local_candidates":[{"FoundAt":"2025-12-05T20:35:36.740999936Z","CandType":"host","IP":"127.0.0.1","Port":63796},{"FoundAt":"2025-12-05T20:35:36.776Z","CandType":"server-reflexive","IP":"73.47.51.100","Port":63401},{"FoundAt":"2025-12-05T20:35:36.740999936Z","CandType":"host","IP":"192.168.0.96","Port":49436}],"conn_remote_candidates":[{"FoundAt":"2025-12-05T20:35:36.9Z","CandType":"peer-reflexive","IP":"127.0.0.1","Port":49324}],"candidate_pair":"(local) udp4 host 127.0.0.1:63796 <-> (remote) udp4 prflx 127.0.0.1:49324 related :0"}
2025-12-05T20:35:36.902Z        INFO    rdk.networking  rpc/wrtc_base_channel.go:136    Diagnostic data for successful webrtc connection attempt        {"conn_id":"PeerConnection-1764966936740501000","conn_local_candidates":[{"FoundAt":"2025-12-05T20:35:36.740999936Z","CandType":"host","IP":"192.168.0.96","Port":49568},{"FoundAt":"2025-12-05T20:35:36.740999936Z","CandType":"host","IP":"127.0.0.1","Port":52254},{"FoundAt":"2025-12-05T20:35:36.774000128Z","CandType":"server-reflexive","IP":"73.47.51.100","Port":59560}],"conn_remote_candidates":[{"FoundAt":"2025-12-05T20:35:36.900999936Z","CandType":"peer-reflexive","IP":"127.0.0.1","Port":56656}],"candidate_pair":"(local) udp4 host 127.0.0.1:52254 <-> (remote) udp4 prflx 127.0.0.1:56656 related :0"}
2025-12-05T20:35:36.999Z        INFO    rdk.network-checks.udp  networkcheck/network-check-types.go:282 7/7 udp STUN tests succeeded    {"udp_tests":"[{stun_server_url: global.stun.twilio.com:3478, stun_server_addr: 34.203.251.221:3478, bind_response_addr: 73.47.51.100:55252, time_to_bind_response_ms: 26},{stun_server_url: turn.viam.com:443, stun_server_addr: 34.123.161.254:443, bind_response_addr: 73.47.51.100:55252, time_to_bind_response_ms: 63},{stun_server_url: turn.viam.com:3478, stun_server_addr: 34.123.161.254:3478, bind_response_addr: 73.47.51.100:55252, time_to_bind_response_ms: 58},{stun_server_url: stun.l.google.com:3478, stun_server_addr: 74.125.250.129:3478, bind_response_addr: 73.47.51.100:55252, time_to_bind_response_ms: 34},{stun_server_url: stun.l.google.com:19302, stun_server_addr: 74.125.250.129:19302, bind_response_addr: 73.47.51.100:55252, time_to_bind_response_ms: 25},{stun_server_url: stun.sipgate.net:3478, stun_server_addr: 3.33.249.248:3478, bind_response_addr: 73.47.51.100:55252, time_to_bind_response_ms: 243},{stun_server_url: stun.sipgate.net:3479, stun_server_addr: 3.33.249.248:3479, bind_response_addr: 73.47.51.100:55252, time_to_bind_response_ms: 237}]","udp_source_address":"[::]:55252"}
2025-12-05T20:35:37.246Z        INFO    rdk.network-checks.tcp  networkcheck/network-check-types.go:282 2/2 tcp STUN tests succeeded    {"tcp_tests":"[{stun_server_url: turn.viam.com:443, tcp_source_address: 192.168.0.96:55081, stun_server_addr: 34.123.161.254:443, bind_response_addr: 73.47.51.100:55081, time_to_bind_response_ms: 60},{stun_server_url: turn.viam.com:3478, tcp_source_address: 192.168.0.96:55082, stun_server_addr: 34.123.161.254:3478, bind_response_addr: 73.47.51.100:55082, time_to_bind_response_ms: 60}]"}
2025-12-05T20:35:37.612Z        WARN    rdk.modmanager.simple2  utils/ticker.go:22      Waiting for module to complete startup and registration {"module":"simple2","time_elapsed":"2s"}
2025-12-05T20:35:38.261Z        INFO    rdk.modmanager.simple2.StdOut   pexec/managed_process.go:444
\_ 2025-12-05T20:35:38.261Z     INFO    simple2 module/runtime.go:19    module version: v0.104.1-0.20251205190843-9e2161cd7867+dirty, go version: go1.25.1
2025-12-05T20:35:38.262Z        INFO    rdk.modmanager.simple2.StdOut   pexec/managed_process.go:444
\_ 2025-12-05T20:35:38.262Z     INFO    simple2 module/module.go:254    server listening at /var/folders/gp/_3v6m84n1hxg26d8pxt4ltrw0000gn/T/viam-module-1270991601/simple2-ASqJH.sock
2025-12-05T20:35:38.315Z        INFO    rdk.modmanager.simple2  modmanager/module.go:123        Waiting for module to respond to ready request  {"module":"simple2"}
2025-12-05T20:35:38.319Z        INFO    rdk.modmanager.simple2.StdOut   pexec/managed_process.go:444
\_ 2025-12-05T20:35:38.319Z     INFO    simple2 client/client.go:522    A WebRTC connection was made to the robot. Reconnects will disallow direct gRPC connections.
2025-12-05T20:35:38.319Z        INFO    rdk.modmanager.simple2.StdOut   pexec/managed_process.go:444
\_ 2025-12-05T20:35:38.319Z     INFO    simple2 client/client.go:493    successfully (re)connected to remote at address {"address":"unix:///var/folders/gp/_3v6m84n1hxg26d8pxt4ltrw0000gn/T/viam-module-1270991601/parent.sock"}
2025-12-05T20:35:38.324Z        INFO    rdk.modmanager.simple2  modmanager/module.go:396        Registering component API and model from module {"module":"simple2","API":"rdk:component:generic","model":"acme:demo:mycounter"}
2025-12-05T20:35:38.324Z        INFO    rdk.modmanager.simple2  modmanager/manager.go:398       Module successfully added       {"module":"simple2"}
2025-12-05T20:35:38.324Z        INFO    rdk.modmanager  modmanager/manager.go:294       Modules successfully added      {"modules":["simple2"]}
2025-12-05T20:35:38.324Z        INFO    rdk.resource_manager    impl/resource_manager.go:782    Now configuring resource        {"resource":"rdk:component:motor/foo","model":"rdk:builtin:fake"}
2025-12-05T20:35:38.324Z        INFO    rdk.resource_manager    impl/resource_manager.go:782    Now configuring resource        {"resource":"rdk:component:generic/c","model":"acme:demo:mycounter"}
2025-12-05T20:35:38.324Z        INFO    rdk.resource_manager.rdk:component:motor/foo    fake/motor.go:129       board not provided, using a fake board
2025-12-05T20:35:38.325Z        INFO    rdk.resource_manager.rdk:component:motor/foo    fake/motor.go:152       Max RPM not provided to a fake motor, defaulting to 100
2025-12-05T20:35:38.325Z        INFO    rdk.resource_manager    impl/resource_manager.go:833    Successfully configured resource        {"resource":"rdk:component:motor/foo","model":"rdk:builtin:fake"}
2025-12-05T20:35:38.325Z        INFO    rdk.modmanager.simple2  modmanager/manager.go:554       Adding resource to module       {"resource":"c","module":"simple2"}
2025-12-05T20:35:38.325Z        INFO    rdk.resource_manager    impl/resource_manager.go:833    Successfully configured resource        {"resource":"rdk:component:generic/c","model":"acme:demo:mycounter"}
2025-12-05T20:35:38.325Z        INFO    rdk.framesystem framesystem/framesystem.go:214  Reconfigured. Known components: map[c:0x14001040880 foo:0x140014b8fc0]
2025-12-05T20:35:38.325Z        INFO    rdk     impl/local_robot.go:1647        Robot (re)configured
2025-12-05T20:35:38.325Z        INFO    rdk.config      server/entrypoint.go:370        Robot reconfigured with full config     {"time_to_reconfigure":"2.714726167s"}
2025-12-05T20:35:46.875Z        INFO    rdk.networking  rpc/wrtc_base_channel.go:136    Diagnostic data for successful webrtc connection attempt        {"conn_id":"PeerConnection-1764966946867099000","conn_local_candidates":[{"FoundAt":"2025-12-05T20:35:46.868Z","CandType":"host","IP":"127.0.0.1","Port":51931},{"FoundAt":"2025-12-05T20:35:46.868Z","CandType":"host","IP":"192.168.0.96","Port":51869}],"conn_remote_candidates":[{"FoundAt":"2025-12-05T20:35:46.873999872Z","CandType":"peer-reflexive","IP":"127.0.0.1","Port":56987}],"candidate_pair":"(local) udp4 host 127.0.0.1:51931 <-> (remote) udp4 prflx 127.0.0.1:56987 related :0"}
2025-12-05T20:37:20.126Z      INFO    rdk     web/web.go:196  Viam RDK shutting down
2025-12-05T20:37:20.126Z        INFO    rdk.networking  rpc/server.go:937       stopping
2025-12-05T20:37:20.126Z        INFO    rdk.networking  rpc/wrtc_server.go:127  waiting for handlers to complete
2025-12-05T20:37:20.128Z        INFO    rdk.networking  rpc/wrtc_server.go:132  handlers complete
2025-12-05T20:37:20.128Z        INFO    rdk.networking  rpc/wrtc_server.go:133  closing lingering peer connections
2025-12-05T20:37:20.128Z        INFO    rdk.networking  rpc/wrtc_server.go:151  lingering peer connections closed
2025-12-05T20:37:20.129Z        INFO    rdk.networking  rpc/server.go:969       stopped cleanly
2025-12-05T20:37:20.130Z        INFO    rdk.resource_manager    impl/resource_manager.go:558    Now removing resource   {"resource":"rdk-internal:service:frame_system/builtin"}
2025-12-05T20:37:20.130Z        INFO    rdk.resource_manager    impl/resource_manager.go:558    Now removing resource   {"resource":"rdk-internal:service:packagemanager/deferred-manager"}
2025-12-05T20:37:20.131Z        INFO    rdk.resource_manager    impl/resource_manager.go:558    Now removing resource   {"resource":"rdk-internal:service:cloud_connection/builtin"}
2025-12-05T20:37:20.131Z        INFO    rdk.resource_manager    impl/resource_manager.go:558    Now removing resource   {"resource":"rdk:component:motor/foo"}
2025-12-05T20:37:20.131Z        INFO    rdk.resource_manager    impl/resource_manager.go:558    Now removing resource   {"resource":"rdk:component:generic/c"}
2025-12-05T20:37:20.131Z        INFO    rdk.modmanager.simple2  modmanager/manager.go:660       Removing resource for module    {"resource":"rdk:component:generic/c","module":"simple2"}
2025-12-05T20:37:20.132Z        INFO    rdk.modmanager.simple2  modmanager/module.go:342        Stopping module: simple2 process
2025-12-05T20:37:20.132Z        INFO    rdk.modmanager.simple2.simple2  pexec/managed_process_unix.go:100       stopping process 56381 with signal terminated
2025-12-05T20:37:20.133Z        INFO    simple2 module/module.go:278    Shutting down gracefully.       {"log_ts":"2025-12-05T20:37:20.132Z"}
2025-12-05T20:37:20.139Z        WARN    rdk.ftdc        ftdc/ftdc.go:210        Did not find statser to remove  {"name":"proc.modules.simple2"}
2025-12-05T20:37:20.141Z        INFO    rdk.modmanager.simple2  modmanager/manager.go:537       Module successfully closed      {"module":"simple2"}
2025-12-05T20:37:20.141Z        INFO    rdk.job_manager jobmanager/jobmanager.go:169    JobManager is shutting down.

When app is running new diagnostic logs logic, the "Logs" tab contains only the following logs of the above by default:

12/5/2025, 3:35:35 PM info rdk   server/entrypoint.go:107   Viam RDK built from source; version unknown
12/5/2025, 3:35:35 PM info rdk   server/entrypoint.go:92   Starting viam-server with following environment variables   HOME /Users/benjirewis
12/5/2025, 3:35:35 PM info rdk.package_manager   packages/deferred_package_manager.go:148   cloud package manager created asyncronously
12/5/2025, 3:35:35 PM warn rdk.modmanager.first_run   config/module.go:300   failed to parse meta.json, skipping first run   error local non-tarball: did not search for meta.json  module simple2
12/5/2025, 3:35:35 PM info rdk   impl/local_robot.go:1591   (Re)configuring robot
12/5/2025, 3:35:35 PM info rdk.modmanager.simple2   modmanager/manager.go:274   Now adding module   module simple2
12/5/2025, 3:35:35 PM info rdk.modmanager.simple2   modmanager/module.go:254   Starting module in working directory   module simple2  dir /Users/benjirewis/Code/Viam/rdk/examples/customresources/demos/simplemodule
12/5/2025, 3:35:35 PM warn rdk.modmanager.simple2   modmanager/module.go:477   Cannot start a system statser for module with pid   err could not read "/proc": stat /proc: no such file or directory
12/5/2025, 3:35:35 PM info rdk.modmanager.simple2   modmanager/module.go:301   Starting up module   module simple2
12/5/2025, 3:35:35 PM info rdk.modmanager.simple2   utils/env.go:179   Starting module with following Viam environment variables   environment [VIAM_HOME=/Users/benjirewis/.viam VIAM_MACHINE_PART_ID=146f1d0f-4452-4eb1-b333-80c393257714 VIAM_API_KEY_ID=643cbf5d-b805-4cbe-a6e5-e8fe08d6f1a3 VIAM_API_KEY=XXXXXXXXXX VIAM_LOCATION_ID=660rm6d3f8 VIAM_MACHINE_FQDN=new-main.660rm6d3f8.viam.cloud VIAM_MODULE_DATA=/Users/benjirewis/.viam/module-data/146f1d0f-4452-4eb1-b333-80c393257714/simple2 VIAM_MODULE_NAME=simple2 VIAM_MODULE_ROOT=/Users/benjirewis/Code/Viam/rdk/examples/customresources/demos/simplemodule VIAM_PRIMARY_ORG_ID=4b786aa9-13d7-4e39-9169-241749f50afe VIAM_MACHINE_ID=d88f09aa-2398-48b6-b52a-1a6b7fc98111]
12/5/2025, 3:35:35 PM info rdk   web/web.go:528   serving   url http://new-main.660rm6d3f8.local.viam.cloud:8082  alt_url http://0.0.0.0:8082
12/5/2025, 3:35:37 PM warn rdk.modmanager.simple2   utils/ticker.go:22   Waiting for module to complete startup and registration   module simple2  time_elapsed 2s
12/5/2025, 3:35:38 PM info rdk.modmanager.simple2.StdOut   pexec/managed_process.go:444   \_ 2025-12-05T20:35:38.261Z INFO simple2 module/runtime.go:19 module version: v0.104.1-0.20251205190843-9e2161cd7867+dirty, go version: go1.25.1
12/5/2025, 3:35:38 PM info rdk.modmanager.simple2.StdOut   pexec/managed_process.go:444   \_ 2025-12-05T20:35:38.262Z INFO simple2 module/module.go:254 server listening at /var/folders/gp/_3v6m84n1hxg26d8pxt4ltrw0000gn/T/viam-module-1270991601/simple2-ASqJH.sock
12/5/2025, 3:35:38 PM info rdk.modmanager.simple2   modmanager/module.go:123   Waiting for module to respond to ready request   module simple2
12/5/2025, 3:35:38 PM info rdk.modmanager.simple2.StdOut   pexec/managed_process.go:444   \_ 2025-12-05T20:35:38.319Z INFO simple2 client/client.go:522 A WebRTC connection was made to the robot. Reconnects will disallow direct gRPC connections.
12/5/2025, 3:35:38 PM info rdk.modmanager.simple2.StdOut   pexec/managed_process.go:444   \_ 2025-12-05T20:35:38.319Z INFO simple2 client/client.go:493 successfully (re)connected to remote at address {"address":"unix:///var/folders/gp/_3v6m84n1hxg26d8pxt4ltrw0000gn/T/viam-module-1270991601/parent.sock"}
12/5/2025, 3:35:38 PM info rdk.modmanager.simple2   modmanager/module.go:396   Registering component API and model from module   module simple2  API rdk:component:generic  model acme:demo:mycounter
12/5/2025, 3:35:38 PM info rdk.modmanager.simple2   modmanager/manager.go:398   Module successfully added   module simple2
12/5/2025, 3:35:38 PM info rdk.modmanager   modmanager/manager.go:294   Modules successfully added   modules [simple2]
12/5/2025, 3:35:38 PM info rdk.resource_manager   impl/resource_manager.go:782   Now configuring resource   resource rdk:component:motor/foo  model rdk:builtin:fake
12/5/2025, 3:35:38 PM info rdk.resource_manager   impl/resource_manager.go:782   Now configuring resource   resource rdk:component:generic/c  model acme:demo:mycounter
12/5/2025, 3:35:38 PM info rdk.resource_manager.rdk:component:motor/foo   fake/motor.go:129   board not provided, using a fake board
12/5/2025, 3:35:38 PM info rdk.resource_manager.rdk:component:motor/foo   fake/motor.go:152   Max RPM not provided to a fake motor, defaulting to 100
12/5/2025, 3:35:38 PM info rdk.resource_manager   impl/resource_manager.go:833   Successfully configured resource   resource rdk:component:motor/foo  model rdk:builtin:fake
12/5/2025, 3:35:38 PM info rdk.modmanager.simple2   modmanager/manager.go:554   Adding resource to module   resource c  module simple2
12/5/2025, 3:35:38 PM info rdk.resource_manager   impl/resource_manager.go:833   Successfully configured resource   resource rdk:component:generic/c  model acme:demo:mycounter
12/5/2025, 3:35:38 PM info rdk   impl/local_robot.go:1647   Robot (re)configured
12/5/2025, 3:37:20 PM info rdk   web/web.go:196   Viam RDK shutting down
12/5/2025, 3:37:20 PM info rdk.resource_manager   impl/resource_manager.go:558   Now removing resource   resource rdk-internal:service:frame_system/builtin
12/5/2025, 3:37:20 PM info rdk.resource_manager   impl/resource_manager.go:558   Now removing resource   resource rdk-internal:service:packagemanager/deferred-manager
12/5/2025, 3:37:20 PM info rdk.resource_manager   impl/resource_manager.go:558   Now removing resource   resource rdk-internal:service:cloud_connection/builtin
12/5/2025, 3:37:20 PM info rdk.resource_manager   impl/resource_manager.go:558   Now removing resource   resource rdk:component:motor/foo
12/5/2025, 3:37:20 PM info rdk.resource_manager   impl/resource_manager.go:558   Now removing resource   resource rdk:component:generic/c
12/5/2025, 3:37:20 PM info rdk.modmanager.simple2   modmanager/manager.go:660   Removing resource for module   resource rdk:component:generic/c  module simple2
12/5/2025, 3:37:20 PM info rdk.modmanager.simple2   modmanager/module.go:342   Stopping module: simple2 process
12/5/2025, 3:37:20 PM info rdk.modmanager.simple2.simple2   pexec/managed_process_unix.go:100   stopping process 56381 with signal terminated
12/5/2025, 3:37:20 PM info simple2     module/module.go:278 Shutting down gracefully.   log_ts 2025-12-05T20:37:20.132Z
12/5/2025, 3:37:20 PM info rdk.modmanager.simple2   modmanager/manager.go:537   Module successfully closed   module simple2

@benjirewis benjirewis requested a review from a team December 3, 2025 21:19
@benjirewis benjirewis marked this pull request as ready for review December 3, 2025 21:19
@benjirewis benjirewis requested review from cheukt and dgottlieb and removed request for a team December 3, 2025 22:27
@benjirewis
Copy link
Member Author

Spoke with @cheukt offline: I'm going to invert the list in app to be diagnosticLoggerNames instead of userFacingLoggerNames and try to make fewer changes in this PR (keep rdk as top-level logger and do less segmenting).

Copy link
Member

@dgottlieb dgottlieb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

edit
Just saw this:

Spoke with @cheukt offline: I'm going to invert the list in app to be diagnosticLoggerNames instead of userFacingLoggerNames and try to make fewer changes in this PR (keep rdk as top-level logger and do less segmenting).

Feel free to read over the feedback -- but don't feel compelled to make a specific change for stuff getting tweaked for the above.

original
Sorry I just stream of consciousness-bombed this PR. Trying to get thoughts out on a limited timeline.

Summarizing my thoughts:

  • The high level PR description of what the top of the logger heirarchy is and what is user-facing/diagnostics makes sense.
  • I see we're again trying to have an empty string logger. I still think rdk.networking is preferable to just networking. Especially cause we changed some logs to say viam-server because, without the context of rdk in the logger name, no one really knows what the log refers to.
    • Not to mention this will be backwards breaking for existing logger patterns.
      • Some backwards breaking is inevitable -- but one of my favorites to disable is rdk.networking.... And I don't think that one needed to happen.
      • We probably have to circle back and consider whether log patterns should actually skip sending logs to app. Or just control whether app renders logs in the logs tab? Definitely not a now problem to solve.
    • I might very well be the only person taking advantage of that anyways.
    • But most importantly, I want to easily verify that nothing is ever outputted over the empty logger.
  • The 3 kinds of module loggers in the modmanager package is confusing
  • There's a bunch of copy changes (read: tweaks to the words in existing log messages). Some make sense given the context of this PR. Some feel like they're drivebys. Many I think are a regression in some aspect of communicating important information. Even if they are an improvement in a different aspect.
    • Can we split this PR into two pieces? The first piece being the logger name refactor. And then a second piece where we can debate copy? I think the logger name refactor is important for moving the project forward. And the copy changes are just a distraction.

}

mod.logger.CInfow(ctx, "Module configuration changed. Stopping the existing module process", "module", conf.Name)
mgr.modulesLogger.CInfow(ctx, "Now reconfiguring module", "module", conf.Name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is better? Why go from the module logger to the manager? I don't think the distinction matters to the user.

And what's the motivation for the copy change? "reconfiguring" isn't well defined. But "configuration changed" and "stopping process" are.

mod.logger.CInfow(ctx, "Resources handled by reconfigured module will be re-added to new module process",
"module", mod.cfg.Name, "resources", handledResourceNameStrings)

mgr.modulesLogger.CInfow(ctx, "Module successfully reconfigured", "module", conf.Name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this tell us that the above two logs are not?

go func(i int, conf config.Module) {
defer wg.Done()
moduleLogger := mgr.logger.Sublogger(conf.Name)
mgr.modulesLogger.CInfow(ctx, "Now adding module", "module", conf.Name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change which logger this goes to? I'm not sure why this is considered preferable.

oue pexec.UnexpectedExitHandler,
viamHomeDir string,
packagesDir string,
modulesLogger logging.Logger,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's three loggers at play:

  • manager logger
  • manager module logger
  • module logger (m.logger)

Given lines 261/262 are sublogger-ing with the module name, I'm guessing this input is the manager module logger and not the module logger? Why are we not using m.logger?

jobManager *jobmanager.JobManager
localPackages packages.ManagerSyncer
cloudConnSvc icloud.ConnectionService
logger logging.Logger
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we creating a convention where logger always refers to a diagnostics logger? The high level PR description makes sense, but I think keeping track of which loggers are which here is going to be rough.

robot/web/web.go Outdated
err = utils.FilterOutError(err, context.Canceled)
if err != nil {
logger.Errorw("error running web", "error", err)
shutdownLogger.Errorw("error running web", "error", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wasn't obvious to me this change was right. As in, is this really a shutdown log? But it is.

Can we undo this weird defer thing? And just assume StartWeb is not being weird and panicing? And maybe change the message to be understandable(-ish) by a user: Error running RPC server. Shutting down.

At least I think startweb's primary purpose is to allow for (g)RPC invocations?

}
if len(versionFields) != 0 {
logger.Infow("Viam RDK", versionFields...)
logger.Infow("viam-server", versionFields...)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grepping for Viam RDK is my goto for finding startup/shutdown periods in logs. Relying heavily on viam-server in logs I feel is going to greatly complicate that workflow. Maybe I'll commit "environment variables" to memory?

I'm not sure when this project decided to declare war on "RDK" (which I can half understand -- it's not really user-friendly).

// modulesLogger is used for adding, removing, and reconfiguring modules as well as
// module log output and is user-facing in app.
modulesLogger logging.Logger
// logger is used for all other module manager logs.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we write out whether this is user facing or not?

There's also the third logger of mod.logger. I'm not sure what the rule is for which of the three to use for logging to. I'm hoping we can get away with just two? The individual module loggers and the mod manager (when not logging about any specific module -- for no modules or potentially multiple modules).

Not to mention the 4th module logger for stdout/stderr and the 5th module logger for module logs sent to the viam-server over gRPC.

globalLogger.mu.Lock()
defer globalLogger.mu.Unlock()

globalLogger.logger = logger
Copy link
Member

@dgottlieb dgottlieb Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing we're never supposed to write logs to logger. But this is the logger we call SetLevel on? Can we enhance the name.

My rule of thumb for naming variables is that -- if only one variable has some type, can just name it after the type. But once two variables have some type, it's easy and effective to come up with non-generic names/adjectives that describe their unique purpose and how the two (or more) variables co-exist.

@benjirewis benjirewis force-pushed the reorganize-subloggers-for-diagnostics branch from 0ad291e to 9e2161c Compare December 5, 2025 19:09
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Dec 5, 2025
Copy link
Member Author

@benjirewis benjirewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks both! Took @cheukt's offline feedback and read through all your comments, @dgottlieb. I won't respond to the GH comments individually since quite a bit has changed in this PR, but I've updated the PR description and my previous comment showing example logs. Generally, I now have a list of hard-coded diagnosticLoggerNames in the app PR instead of userFacingLoggerNames, and have avoided unnecessary segmentation/copy changes. Let me know what you think!

@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Dec 5, 2025
Copy link
Member Author

@benjirewis benjirewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed further offline: I've removed "rdk.modmanager.", "rdk.package_manager", and "rdk.resource_manager" from the list of diagnostic logger names in the app PR. I've also removed all changes to module/modmanager/manager.go (no need to move anything from rdk.modmanager.[modulename] to rdk.modmanager). Finally, I updated the PR description and my previous comment showing example logs once more. This PR basically just adds a "rdk.config" Sublogger now.

@cheukt I found that rdk.package_manager should probably be user-facing; it does indeed log the download percentage of all packages, and I was making it diagnostic only to hide a single startup and a single shutdown log.

Let me know what you think! The final set of user-facing logs seems succinct enough but also more conservatively includes information.

golog.ReplaceGloabl(logger.AsZap())
// Have goutils use the networking Sublogger of the root logger we've just configured.
// most of goutils is related to networking logic.
golog.ReplaceGloabl(networkingLogger.AsZap())
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see no usages of the golog dependency anywhere but here in rdk, @dgottlieb.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the change to the networking logger here is correct. In fact I only see one networking log (by number of lines -- not necessarily by number of invocations):

rpc/dialer.go:                          golog.Global().Debugw("close referenced conn", "proto", rc.proto)

I'm not sure what the remark is suggesting, but I think the question is -- is this "safe" to remove?

If I remember correctly, I had (presumably also) thought we could remove this (and did). But then learned that there were logs in goutils that used the golog global logger. And those logs stopped getting sent to app. I think the most damaging logs to omit were those from panic capturing go. But there's also UncheckedError (and family).

I don't know if those need to be user-facing, so networkingLogger here might be fine. But want to make an intentional choice here.

W.r.t potentially removing this: I think we can only remove this for real once goutils stops relying on the global golog logger.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking more closely at the usages of the global logger in goutils, it does seem like it's NOT necessarily used for "networking"-related messages in goutils:

testutils/ext/verify.go:
70:             golog.Global().Fatalw("error opening artifact", "error", err)
76:             golog.Global().Errorw("error closing artifact", "error", err)
testutils/env.go:
15:     logger            = golog.Global().Named("test")
runtime.go:
153:                            golog.Global().Errorw("panic while running function", "error", err)
158:                            golog.Global().Infow("waiting a bit to call callback", "wait", waitDur.String())
logger.go
15:var Logger = golog.Global()
perf/statz/summations.go:
96:             golog.Global().Errorf("faild to write metric %s", err)
web/templates.go:
219:                    golog.Global().Errorf("protoJson failed to marshal: %s", err)
perf/statz/counters.go:
112:                    golog.Global().Errorf("faild to write metric %s", err)
error.go:
65:     golog.Global().Desugar().WithOptions(zap.AddCallerSkip(2)).Sugar().Debugw("unchecked error", "error", err)
perf/statz/statztest/recorder.go:
138:            golog.Global().Panic("Expected even number of keypairs")
perf/statz/gauges.go:
81:             golog.Global().Errorf("faild to write metric %s", err)
rpc/dialer.go:
215:                            golog.Global().Debugw("close referenced conn", "proto", rc.proto)
perf/statz/wrapper.go:
19:             golog.Global().Panic("Should never happen where the label lengths do not match")
perf/statz/internal/global.go:
39:             golog.Global().Panicf(`Metric %s was already defined and is trying to register again. It may be registered at: %s
rpc/examples/echo/client/main.go:
22:var logger utils.ZapCompatibleLogger = golog.Global().Named("client")
perf/statz/distributions.go:
90:             golog.Global().Errorf("faild to write metric %s", err)
perf/statz/example/example.go:
40:             golog.Global().Panicf("Failed to start: %s", err)
51:             golog.Global().Infof("Latency %d: %f", i, ms)
perf/statz/lables.go:
48:             golog.Global().Fatalf("Invalid type to string, should never happen with the type contraints defined.")
58:                     golog.Global().Fatalf("error creating metric label", err)
perf/statz/statz.go:
255:            golog.Global().Panicf("Failed to register metric name not valid: %s", err)
261:                    golog.Global().Panicf("Failed to register metric label not valid: %s", err)
286:            golog.Global().Fatalf("Failed to register the views: %v", err)
298:            golog.Global().Panic("Regex failed, this should not happen")
312:            golog.Global().Panic("Regex failed, this should not happen")
rpc/examples/echo/server/cmd/main.go:
36:     logger      utils.ZapCompatibleLogger = golog.Global().Named("server")

Of those search results, I think the only instances that represent non-testing and non-example logs are:

runtime.go:
153:                            golog.Global().Errorw("panic while running function", "error", err)
158:                            golog.Global().Infow("waiting a bit to call callback", "wait", waitDur.String())
logger.go
15:var Logger = golog.Global()
perf/statz/summations.go:
96:             golog.Global().Errorf("faild to write metric %s", err)
web/templates.go:
219:                    golog.Global().Errorf("protoJson failed to marshal: %s", err)
perf/statz/counters.go:
112:                    golog.Global().Errorf("faild to write metric %s", err)
error.go:
65:     golog.Global().Desugar().WithOptions(zap.AddCallerSkip(2)).Sugar().Debugw("unchecked error", "error", err)
perf/statz/statztest/recorder.go:
138:            golog.Global().Panic("Expected even number of keypairs")
perf/statz/gauges.go:
81:             golog.Global().Errorf("faild to write metric %s", err)
rpc/dialer.go:
215:                            golog.Global().Debugw("close referenced conn", "proto", rc.proto)
perf/statz/wrapper.go:
19:             golog.Global().Panic("Should never happen where the label lengths do not match")
perf/statz/internal/global.go:
39:             golog.Global().Panicf(`Metric %s was already defined and is trying to register again. It may be registered at: %s
perf/statz/distributions.go:
90:             golog.Global().Errorf("faild to write metric %s", err)
perf/statz/example/example.go:
40:             golog.Global().Panicf("Failed to start: %s", err)
51:             golog.Global().Infof("Latency %d: %f", i, ms)
perf/statz/lables.go:
48:             golog.Global().Fatalf("Invalid type to string, should never happen with the type contraints defined.")
58:                     golog.Global().Fatalf("error creating metric label", err)
perf/statz/statz.go:
255:            golog.Global().Panicf("Failed to register metric name not valid: %s", err)
261:                    golog.Global().Panicf("Failed to register metric label not valid: %s", err)
286:            golog.Global().Fatalf("Failed to register the views: %v", err)
298:            golog.Global().Panic("Regex failed, this should not happen")
312:            golog.Global().Panic("Regex failed, this should not happen")

Note that that var Logger = golog.Global() variable is never referenced, so that declaration is a no-op. The rest of the instances are primarily from metrics-related logic, with some random runtime, error-checking, "template" (app-related auth concept I think), and networking logs thrown in. It's probably best to just use rdk for this random assortment of logs. If they end up being noisy/diagnostic, we can create a separate logger here, but I agree with you that rdk.networking does not seem correct.

TL;DR I'm going to change this line to be golog.ReplaceGloabl(rootLogger.AsZap())

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with that change

@benjirewis benjirewis requested a review from dgottlieb December 8, 2025 20:40
return
}
globalLogger.logger.Info("New log level:", newLevelZap)
globalLogger.levelChangeLogger.Info("New log level:", newLevelZap)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Err, I'll take the blame for this. I guess this was a perceived bugfix?

Now that I see this more clearly(read: without the other code change distractions), I see why this second logger was introduced onto the globalLogger. I'm less happy about my ask to better name what's now globalLogger.actualGlobalLogger.

No need to change this. These loggers aren't explicitly referenced in many spots. So whatever blemish I perceive is inconsequential. Putting myself in your shoes, I would have tried to brainstorm options for avoiding needing a different logger here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha; I'm gonna leave the names of actualGlobalLogger and levelChangeLogger as-is (IIUC your comment correctly), but I do agree with the "grossness" of globalLogger.actualGlobalLogger 😆 .

golog.ReplaceGloabl(logger.AsZap())
// Have goutils use the networking Sublogger of the root logger we've just configured.
// most of goutils is related to networking logic.
golog.ReplaceGloabl(networkingLogger.AsZap())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the change to the networking logger here is correct. In fact I only see one networking log (by number of lines -- not necessarily by number of invocations):

rpc/dialer.go:                          golog.Global().Debugw("close referenced conn", "proto", rc.proto)

I'm not sure what the remark is suggesting, but I think the question is -- is this "safe" to remove?

If I remember correctly, I had (presumably also) thought we could remove this (and did). But then learned that there were logs in goutils that used the golog global logger. And those logs stopped getting sent to app. I think the most damaging logs to omit were those from panic capturing go. But there's also UncheckedError (and family).

I don't know if those need to be user-facing, so networkingLogger here might be fine. But want to make an intentional choice here.

W.r.t potentially removing this: I think we can only remove this for real once goutils stops relying on the global golog logger.

golog.ReplaceGloabl(networkingLogger.AsZap())

go nc.RunNetworkChecks(ctx, logger, true /* continueRunningTestDNS */)
go nc.RunNetworkChecks(ctx, rootLogger, true /* continueRunningTestDNS */)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this is the root logger so it's user facing? Not sure if I agree with that (certainly more interesting to users than weird internal RDK stuff, but not sure they can do much about).

I think being conservative and leaving as rootLogger here is fine. Can we leave a comment reminding readers these are considered user-facing. And clarifying there's no hard opinion on whether that's right? Or maybe there is a hard opinion -- just speculating here to reduce round trips in PR review in case I guessed correctly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this is the root logger so it's user facing?

While we are passing the rootLogger to RunNetworkChecks, that function immediately creates a sublogger rdk.network-checks which is listed as diagnostic in the app PR. Does that resolve your concern? Or, would a comment of some sort still be helpful?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a comment here would be good. I've struggled on where to create subloggers that cross method boundaries.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment.

I've struggled on where to create subloggers that cross method boundaries.

Same... creating a Sublogger before the method invocation or at the top of the method body seem equally valid to me. I suppose it's more of a question of consistency, but we clearly already have both patterns lying around. Documenting which logger will be used when it's a question of user-facing vs. diagnostic seems like a fair solution for now.

}
if host == "" || host == "0.0.0.0" || host == "::" {
s.logger.Warn("binding to all interfaces without authentication")
s.networkingLogger.Warn("binding to all interfaces without authentication")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nuanced take -- keep this as user-facing. Either as the root logger or probably the config logger. This log has important security implications that users have control over.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either as the root logger or probably the config logger.

I made the log user-facing under the root logger, as the config logger is diagnostic. Let me know if that seems off. Also left a comment above the log explaining why it's under the root logger.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood re: config logger. Root is good

// handling restart checking for us (relevant environment variable is unset).
if fullProcessedConfig.Cloud != nil && os.Getenv(rutils.ViamAgentHandlesNeedsRestartChecking) == "" {
s.logger.CInfo(ctx, "Agent does not handle checking needs restart functionality; will handle in server")
s.networkingLogger.CInfo(ctx, "Agent does not handle checking needs restart functionality; will handle in server")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seemed fine to keep as the rootLogger.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to rootLogger.


if mustRestart {
logStackTraceAndCancel(cancel, s.logger)
logStackTraceAndCancel(cancel, s.rootLogger)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we wanted to make these diagnostic logs? Perfectly happy to do this in a different ticket (certainly using the available networkLogger is a bit of a semantic stretch -- and this ticket doesn't need to be scoped to include that).

Just double checking we're on the same page about the long-term goal here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we wanted to make these diagnostic logs?

We do! Cheuk and I agree they should be diagnostic. Mind if I handle that in https://viam.atlassian.net/browse/RSDK-12813?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfectly fine!


shutdownCallbackOpt := robotimpl.WithShutdownCallback(func() {
logStackTraceAndCancel(cancel, s.logger)
logStackTraceAndCancel(cancel, s.rootLogger)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same remark re: long term goal.

@benjirewis benjirewis requested a review from dgottlieb December 10, 2025 17:51
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Dec 10, 2025
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Dec 10, 2025
@benjirewis benjirewis merged commit 0157690 into viamrobotics:main Dec 10, 2025
19 checks passed
@benjirewis benjirewis deleted the reorganize-subloggers-for-diagnostics branch December 10, 2025 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test This pull request is marked safe to test from a trusted zone

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants