Skip to content

Commit 5f514de

Browse files
committed
Document formatter::transform
1 parent fe794b1 commit 5f514de

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ namespace cpptrace {
348348
formatter& columns(bool);
349349
formatter& filtered_frame_placeholders(bool);
350350
formatter& filter(std::function<bool(const stacktrace_frame&)>);
351+
formatter& transform(std::function<stacktrace_frame(stacktrace_frame)>);
351352

352353
std::string format(const stacktrace_frame&) const;
353354
std::string format(const stacktrace_frame&, bool color) const;
@@ -384,6 +385,7 @@ Options:
384385
| `columns` | Whether to include column numbers if present | `true` |
385386
| `filtered_frame_placeholders` | Whether to still print filtered frames as just `#n (filtered)` | `true` |
386387
| `filter` | A predicate to filter frames with | None |
388+
| `transform` | A transformer which takes a stacktrace frame and modifies it | None |
387389
388390
The `automatic` color mode attempts to detect if a stream that may be attached to a terminal. As such, it will not use
389391
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 {
400402
}
401403
```
402404

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+
403419
## Configuration
404420
405421
`cpptrace::absorb_trace_exceptions`: Configure whether the library silently absorbs internal exceptions and continues.

0 commit comments

Comments
 (0)