# class Debugger | An object that logs messages on creation and destruction. More...
Full name | `TelEngine::Debugger`
Definition | `#include <yateclass.h>`
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

#### Public Types

- enum Formatting { None = 0, Relative, Absolute, Textual, TextLocal, TextSep, TextLSep, }

#### Public Methods

- explicit Debugger (const char* name, const char* format = 0, ...)
- Debugger (int level, const char* name, const char* format = 0, ...)
- ~Debugger ()

#### Public Static Methods

- static void setOutput (void (*outFunc)(const char*,int) = 0)
- static void setIntOut (void (*outFunc)(const char*,int) = 0)
- static void setAlarmHook (void (*alarmFunc)(const char*,int,const char*,const char*) = 0)
- static void setRelayHook (void (*relayFunc)(int,const char*,const char*,const char*) = 0)
- static void enableOutput (bool enable = true, bool colorize = false)
- static uint32_t getStartTimeSec ()
- static Formatting getFormatting ()
- static void setFormatting (Formatting format, uint32_t startTimeSec = 0)
- static unsigned int formatTime (char* buf, Formatting format = getFormatting())
- static void relayOutput (int level, char* buffer, const char* component = 0, const char* info = 0)

## Detailed Description

This class is used as an automatic variable that logs messages on creation and destruction (when the instruction block is left or function returns). IMPORTANT: the name is not copied so it should best be static.

enum Formatting { None = 0, Relative, Absolute, Textual, TextLocal, TextSep, TextLSep, } | ### Formatting

Timestamp formatting

explicit Debugger (const char* name, const char* format = 0, ...) | ### Debugger

The constructor prints the method entry message and indents.

Parameters:

name | Name of the function or block entered, must be static
format | printf() style format string

Debugger (int level, const char* name, const char* format = 0, ...) | ### Debugger

The constructor prints the method entry message and indents.

Parameters:

level | The level of the message
name | Name of the function or block entered, must be static
format | printf() style format string

~Debugger () | ### ~Debugger

The destructor prints the method leave message and deindents.

void setOutput (void (*outFunc)(const char*,int) = 0) | ### setOutput

[static]

Set the output callback

Parameters:

outFunc | Pointer to the output function, NULL to use stderr

void setIntOut (void (*outFunc)(const char*,int) = 0) | ### setIntOut

[static]

Set the interactive output callback

Parameters:

outFunc | Pointer to the output function, NULL to disable

void setAlarmHook (void (*alarmFunc)(const char*,int,const char*,const char*) = 0) | ### setAlarmHook

[static]

Set the alarm hook callback

Parameters:

alarmFunc | Pointer to the alarm callback function, NULL to disable

void setRelayHook (void (*relayFunc)(int,const char*,const char*,const char*) = 0) | ### setRelayHook

[static]

Set the relay hook callback that will process all Output, Debug and Alarm

Parameters:

relayFunc | Pointer to the relay callback function, NULL to disable

void enableOutput (bool enable = true, bool colorize = false) | ### enableOutput

[static]

Enable or disable the debug output

Parameters:

enable | Set to true to globally enable output
colorize | Enable ANSI colorization of output

uint32_t getStartTimeSec () | ### getStartTimeSec

[static]

Retrieve the start timestamp

Returns: Start timestamp value in seconds

Formatting getFormatting () | ### getFormatting

[static]

Retrieve the format of timestamps

Returns: The current formatting type for timestamps

void setFormatting (Formatting format, uint32_t startTimeSec = 0) | ### setFormatting

[static]

Set the format of timestamps on output messages and set the time start reference

Parameters:

format | Desired timestamp formatting
startTimeSec | Optional start timestamp (in seconds)

unsigned int formatTime (char* buf, Formatting format = getFormatting()) | ### formatTime

[static]

Fill a buffer with a current timestamp prefix

Parameters:

buf | Buffer to fill, must be at least 24 characters long
format | Desired timestamp formatting

Returns: Length of the prefix written in buffer excluding final NUL

void relayOutput (int level, char* buffer, const char* component = 0, const char* info = 0) | ### relayOutput

[static]

Processes a preformatted string as Output, Debug or Alarm. This method is intended to relay messages from other processes, DO NOT USE!

Parameters:

level | The level of the debug or alarm, negative for an output
buffer | Preformatted text buffer, MUST HAVE SPACE for at least strlen + 2
component | Component that emits the alarm if applicable
info | Extra alarm information if applicable

Generated by: paulc on bussard on Fri May 8 12:37:22 2015, using kdoc 2.0a54.