Skip to content

Improve jsonrpc log messages #381

Description

@diegonehab

Context

Since Boost 1.79, boost::system::error_code::what() appends a source_location suffix (file path, line, column, and full template-expanded function signature) when the error code was constructed with location data -- which Asio does pervasively.
The cartesi-jsonrpc-machine server uses ec.what() in its three network error log sites, so a routine Broken pipe on client disconnect produces a line like:

2026-04-21 18-41-37 error cartesi-jsonrpc-machine pid:18768 ppid:18752 pgid:16351 send response error:Broken pipe [system:32 at /opt/local/libexec/boost/1.87/include/boost/asio/detail/reactive_socket_send_op.hpp:173:37 in function 'static void boost::asio::detail::reactive_socket_send_op<boost::beast::buffers_prefix_view<boost::span<boost::asio::const_buffer>>, ...>']

The suffix is useful for debugging but is noise at normal log levels, and makes log parsing harder.

Expected behavior

At info, warning, error, and fatal log levels the Boost source_location suffix should be omitted; the message should read simply send response error:Broken pipe.

Actual behavior

The full suffix is always included regardless of log level.

Steps to reproduce

Run cartesi-jsonrpc-machine with Boost >= 1.79 at default log level (warning) and trigger a client disconnect (e.g., open a TCP connection and close it abruptly mid-request).

Environment

  • Emulator version: main branch
  • Boost >= 1.79 (source_location support added)

Possible solutions

Use ec.message() (plain message, no suffix) except when the configured log level is trace or debug, in which case use ec.what() (full message with suffix).
Affected sites in src/jsonrpc-remote-machine.cpp: read request error, send response error, accept error.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request
No fields configured for Feature.

Projects

Status
PR Available

Relationships

None yet

Development

No branches or pull requests

Issue actions