Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to customize how objects are repr()'d #67

Open
brianr opened this issue Aug 28, 2015 · 6 comments
Open

Ability to customize how objects are repr()'d #67

brianr opened this issue Aug 28, 2015 · 6 comments

Comments

@brianr
Copy link
Member

brianr commented Aug 28, 2015

pyrollbar uses reprlib to get representations of objects gathered as local variables. This means that to customize it, the only current option is to define/override __repr__. That isn't a good option in some cases, including:

  • objects coming from external libraries
  • objects where something else depends on the existing __repr__ implementation

Creating this issue to discuss the design for how to make this customizable.

@coryvirok
Copy link
Contributor

Thanks for starting the convo, Brian.

I would probably expose a new configuration option that would allow the user to provide a function that would be used instead of __repr__() when serializing the local variable data.

e.g.

# Ordered list of serializers. The first regex pattern that 
# matches the object being serialized will be used. 
# If none of the user-supplied patterns match, the default 
# reprlib.repr() serializer will be used.
serializers = [
  ('class_name_regex_pattern', my_custom_serializer_fn)
  ('*', reprlib.repr)
]

@sibson
Copy link
Contributor

sibson commented Feb 16, 2016

+1 as is. It might be nice to support a __rollbar_repr__() convention of some kind for internal code.

@jfarrimo
Copy link
Contributor

jfarrimo commented Mar 1, 2016

We need to make sure the solution to this addresses the problem that this pull request attempted to address. #91

@rivkahstandig3636
Copy link
Contributor

Hi there, I’m closing out all issues opened before 2018 that haven’t had any activity on them since the start of this year. If this is still an issue for you, please comment here and we can reopen this. Thanks!

@dariatsenter
Copy link

Would be nice to have this option!

@bxsx bxsx reopened this Jan 20, 2022
@bxsx bxsx removed this from the v1.0.0 milestone Jan 20, 2022
@danstewart
Copy link

Another option here could be to use devtools for formatting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants