Tracer  v0.0.1
A platform independant stack trace generator
tracer::TracerHandler Class Referencefinal

Signal handling class. More...

#include <TracerHandler.hpp>

Classes

struct  Config
 User configuration. More...
 

Public Types

typedef void(* callBackPTR) (Tracer *tracer, AbstractPrinter *printer, void *userData)
 The typedef callback for the user.
 

Public Member Functions

Config getConfig () const
 Returns the current configuration.
 
void setConfig (Config c)
 Sets the new configuration.
 
bool setup (PrinterContainer printerToUse)
 Sets everything up with a custom printer.
 
bool defaultSetup ()
 Basic setup, sufficient for most use cases.
 

Static Public Member Functions

static TracerHandlergetTracer ()
 Returns a pointer to the TracerHandler object.
 
static void reset ()
 Resets the singleton.
 

Detailed Description

Signal handling class.

Description

This singleton manages system signals (SIGINT, SIGSEGV, etc.) it provide a signal handler that can print a stack trace to stderr and / or a file. It also calls a user provided function pointer if defined.

Usage

Simple setup

This will print a stack trace using the default Printer (FancyPrinter) and the default Config (TracerHandler::Config)

More advanced setup

With this setup it is possible to customize the output and signal handler.

auto *tHandler = TracerHandler::getTracer(); // Get the singleton
auto cfg = tHandler->getConfig(); // Get the current config
// Edit cfg
tHandler->setConfig(cfg); // Update the config
auto printer = PrinterContainer::fancy(); // Generates a printer
// Edit printer config
tHandler->setup(std::move(printer)); // Sets things up. Now the signal handler is setup

Definition at line 72 of file TracerHandler.hpp.


The documentation for this class was generated from the following files: