@@ -348,6 +348,7 @@ namespace cpptrace {
348
348
formatter& columns(bool);
349
349
formatter& filtered_frame_placeholders(bool);
350
350
formatter& filter(std::function<bool(const stacktrace_frame&)>);
351
+ formatter& transform(std::function<stacktrace_frame(stacktrace_frame)>);
351
352
352
353
std::string format(const stacktrace_frame&) const;
353
354
std::string format(const stacktrace_frame&, bool color) const;
@@ -384,6 +385,7 @@ Options:
384
385
| `columns` | Whether to include column numbers if present | `true` |
385
386
| `filtered_frame_placeholders` | Whether to still print filtered frames as just `#n (filtered)` | `true` |
386
387
| `filter` | A predicate to filter frames with | None |
388
+ | `transform` | A transformer which takes a stacktrace frame and modifies it | None |
387
389
388
390
The `automatic` color mode attempts to detect if a stream that may be attached to a terminal. As such, it will not use
389
391
colors for the `formatter::format` method and it may not be able to detect if some ostreams correspond to terminals or
@@ -400,6 +402,20 @@ namespace cpptrace {
400
402
}
401
403
```
402
404
405
+ ### Transforming
406
+
407
+ A transform function can be specified for the formatter. This function is called before the configured ` filter ` is
408
+ checked. For example:
409
+
410
+ ``` cpp
411
+ auto formatter = cpptrace::formatter{}
412
+ .transform([](cpptrace::stacktrace_frame frame) {
413
+ frame.symbol = replace_all(frame, "std::__cxx11::", "std::");
414
+ return frame;
415
+ });
416
+ ```
417
+
418
+
403
419
## Configuration
404
420
405
421
`cpptrace::absorb_trace_exceptions`: Configure whether the library silently absorbs internal exceptions and continues.
0 commit comments