Skip to content

Commit

Permalink
docs: describe failure writer
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiud committed Jun 12, 2024
1 parent d49e700 commit 5cf7a9a
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions docs/failures.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,33 @@ from the signal handler.
@ 0x7f892f7ef1c4 (unknown)
@ 0x4046f9 (unknown)

By default, the signal handler writes the failure dump to the standard
error. You can customize the destination by
`#!cpp InstallFailureWriter()`.

## Customizing Handler Output

By default, the signal handler writes the failure dump to the standard error.
However, it is possible to customize the destination by installing a callback
using the `#!cpp google::InstallFailureWriter()` function. The function expects
a pointer to a function with the following signature:

``` cpp
void YourFailureWriter(const char* message/* (1)! */, std::size_t length/* (2)! */);
```
1. The pointer references the start of the failure message.
!!! danger
The string is **not null-terminated**.
2. The message length in characters.
!!! warning "Possible overflow errors"
Users should not expect the `message` string to be null-terminated.
## User-defined Failure Function
`FATAL` severity level messages or unsatisfied `CHECK` condition
terminate your program. You can change the behavior of the termination
by `InstallFailureFunction`.
by `google::InstallFailureFunction`.
``` cpp
void YourFailureFunction() {
Expand Down

0 comments on commit 5cf7a9a

Please sign in to comment.