Modify

Opened 5 years ago

Last modified 5 years ago

#10052 new defect

Exception logging in XML-RPC and JSON-RPC is different

Reported by: Karl Owned by: Odd Simon Simonsen
Priority: normal Component: XmlRpcPlugin
Severity: normal Keywords:
Cc: Olemis Lang Trac Release: 0.12

Description

Exceptions raised in the XML-RPC component are logged in the send_rpc_error() method. The corresponding method in the JSON-RPC method does not include any logging.

This means that tracebacks are shown to the user, but don't exist in the logs, which is an issue for debugging.

I've attached a patch which simply adds a log.exception call to the JSON-RPC send_rpc_error method.

Attachments (1)

jsonrpc_logging_v2.patch (529 bytes) - added by Karl 5 years ago.

Download all attachments as: .zip

Change History (3)

Changed 5 years ago by Karl

Attachment: jsonrpc_logging_v2.patch added

comment:1 Changed 5 years ago by Olemis Lang

It'd be nice to have a generic solution for this i.e. log.exception always called from a single location no matter what RPC protocol handler is involved .

comment:2 Changed 5 years ago by Odd Simon Simonsen

A few comments:

  1. Having each handler log errors as it wants is fine by me. Somehow doing this in a shared location will just add complicated scaffolding with entangled code that will just come back and bite us later. I'm fine with the approach suggested in the patch.
  2. I don't think log.exception() is available for all the versions of Trac the plugin supports, and just for this purpose I added tracrpc.util.exception_to_unicode() compat handling to ensure we have a way that works for all. Grep the code to see examples of its use.
  3. I actually don't think you can do logging as the last line if send_rpc_error(). Does that really work? _send_response() will actually raise RequestDone which in turn should abort any further execution. Move the exception logging one line up to log before sending the response.

Care to update the patch?

Modify Ticket

Action
as new The owner will remain Odd Simon Simonsen.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.