## Debug

Debug — Debugging facilities.

## Functions

#define | MIRAGE_DEBUG()
#define | MIRAGE_DEBUG_ON()
#define | MIRAGE_DEBUG_PRINT_BUFFER()

## Types and Values

enum | MirageDebugMask

## Includes

    #include <mirage-debug.h>

## Description

libMirage supports changing of debug message verbosity on fly, without the need to restart the application. This is achieved by using MirageContext objects, which are attached to objects implementing MirageContextual interface. Such an object is MirageObject, which can obtain context from its parent. This way, all objects in the hierarchy share the same context, and same debug verbosity setting.

Debug verbosity can be controlled via mask, which can be set to the context using `mirage_context_set_debug_mask()`. See MirageDebugMasks. The actual printing of debug messages within the code is achieved by `mirage_contextual_debug_messagev()` or `mirage_contextual_debug_message()`, or by convenience macro `MIRAGE_DEBUG()`.

## Functions

### MIRAGE_DEBUG()

    #define MIRAGE_DEBUG(obj, lvl, ...) mirage_contextual_debug_message(MIRAGE_CONTEXTUAL(obj), lvl, __VA_ARGS__)

Debugging macro, provided for convenience. It performs cast to MirageContextual interface on `obj` and calls `mirage_contextual_debug_message()` with debug level `lvl` and debug message, specified by format string and format arguments.

#### Parameters

obj | object. | [in]
lvl | debug level. | [in]
... | debug message. | [in]

### MIRAGE_DEBUG_ON()

    #define MIRAGE_DEBUG_ON(obj, lvl) mirage_contextual_debug_is_active(MIRAGE_CONTEXTUAL(obj), lvl)

Debugging macro, provided for convenience. It performs cast to MirageContextual interface on `obj` and calls `mirage_contextual_debug_is_active()` with debug level `lvl` .

#### Parameters

obj | object. | [in]
lvl | debug level. | [in]

### MIRAGE_DEBUG_PRINT_BUFFER()

    #define MIRAGE_DEBUG_PRINT_BUFFER(obj, lvl, prefix, width, buffer, buffer_length) mirage_contextual_debug_print_buffer(MIRAGE_CONTEXTUAL(obj), lvl, prefix, width, buffer, buffer_length)

Debugging macro, provided for convenience. It performs cast to MirageContextual interface on `obj` and calls `mirage_contextual_debug_print_buffer()` with given arguments.

#### Parameters

obj | object. | [in]
lvl | debug level. | [in]
prefix | prefix, or none. | [in][allow-none]
width | output width. | [in]
buffer | buffer to print. | [in][array length=buffer_length]
buffer_length | buffer length. | [in]

## Types and Values

### enum MirageDebugMask

Debug message types and debug masks used to control verbosity of various parts of libMirage.

All masks except `MIRAGE_DEBUG_ERROR` and `MIRAGE_DEBUG_WARNING` can be combined together to control verbosity of libMirage.

#### Members

MIRAGE_DEBUG_ERROR | error message |
MIRAGE_DEBUG_WARNING | warning message |
MIRAGE_DEBUG_PARSER | message belonging to image parser and file stream parser |
MIRAGE_DEBUG_DISC | message belonging to disc |
MIRAGE_DEBUG_SESSION | message belonging to session |
MIRAGE_DEBUG_TRACK | message belonging to track |
MIRAGE_DEBUG_SECTOR | message belonging to sector |
MIRAGE_DEBUG_FRAGMENT | message belonging to fragment |
MIRAGE_DEBUG_CDTEXT | message belonging to CD-TEXT encoder/decoder |
MIRAGE_DEBUG_STREAM | messages belonging to file and filter stream I/O operations |
MIRAGE_DEBUG_IMAGE_ID | messages belonging to image identification part of image parsers |
MIRAGE_DEBUG_WRITER | messages belonging to image writer |

## See Also

MirageContext, MirageContextual