Skip to content

Optionally trim large messages before logging them #65

@ferrouswheel

Description

@ferrouswheel

In some of our uses of jsonrpcserver, we need to pass base64 encoded images or other binary data. These values end up quite large and the logging becomes unusable.

It'd be nice to have an optional feature where messages are intelligentally trimmed before being logged.

e.g. instead of

--> {"jsonrpc": "2.0", "method": "process_image", "params": {"image": "PmsDHtlHggNoYpvmDfe8NLuLLjk9qGa90my6ZU3qTybG9u7phBaZYGGDGCRmZEg95qTR7O7uLdd9qlilla0rdbffUQltgHKUA9wTirVhqul2Fle6bpOmjUnruHRcupCA3I8wKiOxAOMU10rutQba1W7Rq2prc3s2jTgTatiJJxzgdu/amN77bWfXuR7DsPj+ai58UNS7htH8o/CCebcbLie238gv/2Q=="}, "id": 1} 

trim the string to:

--> {"jsonrpc": "2.0", "method": "process_image", "params": {"image": "PmsDHtlHgg...38gv/2Q=="}, "id": 1} 

The above is an example to demonstrate the idea, but in our situation the string is 100s of lines on the terminal.

There's other ways to format this, e.g. the ... could be ...[532 chars]... to indicate overal length. And large lists or dictionaries could be abbreviated to only show some values... but simply abbreviating large strings would make things nicer for us.

I could try to implement this feature as a PR if you think it'd be useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions