Log4gPatternConverter

Log4gPatternConverter — Provide formatting functionality for pattern converters

Synopsis

                    Log4gPatternConverter;
                    Log4gPatternConverterClass;
enum                Log4gPatternConverterType;
const gchar *       log4g_pattern_converter_convert     (Log4gPatternConverter *self,
                                                         Log4gLoggingEvent *event);
void                log4g_pattern_converter_format      (Log4gPatternConverter *self,
                                                         GString *string,
                                                         Log4gLoggingEvent *event);
Log4gPatternConverter * log4g_pattern_converter_get_next
                                                        (Log4gPatternConverter *self);
void                log4g_pattern_converter_set_next    (Log4gPatternConverter *self,
                                                         Log4gPatternConverter *next);
void                log4g_pattern_converter_space_pad   (const Log4gPatternConverter *self,
                                                         GString *buffer,
                                                         gint length);
const gchar         (*Log4gPatternConverterConvert)     (Log4gPatternConverter *self,
                                                         Log4gLoggingEvent *event);
void                (*Log4gPatternConverterFormat)      (Log4gPatternConverter *self,
                                                         GString *string,
                                                         Log4gLoggingEvent *event);
                    Log4gLiteralPatternConverter;
struct              Log4gLiteralPatternConverterClass;
Log4gPatternConverter * log4g_literal_pattern_converter_new
                                                        (const gchar *pattern);
                    Log4gBasicPatternConverter;
struct              Log4gBasicPatternConverterClass;
Log4gPatternConverter * log4g_basic_pattern_converter_new
                                                        (struct Log4gFormattingInfo *formatting,
                                                         Log4gPatternConverterType type);
                    Log4gDatePatternConverter;
                    Log4gDatePatternConverterClass;
Log4gPatternConverter * log4g_date_pattern_converter_new
                                                        (struct Log4gFormattingInfo *formatting,
                                                         gchar *format);
                    Log4gLocationPatternConverter;
struct              Log4gLocationPatternConverterClass;
Log4gPatternConverter * log4g_location_pattern_converter_new
                                                        (struct Log4gFormattingInfo *formatting,
                                                         Log4gPatternConverterType type);
                    Log4gMDCPatternConverter;
                    Log4gMDCPatternConverterClass;
Log4gPatternConverter * log4g_mdc_pattern_converter_new (struct Log4gFormattingInfo *formatting,
                                                         gchar *key);
                    Log4gCategoryPatternConverter;
struct              Log4gCategoryPatternConverterClass;
Log4gPatternConverter * log4g_category_pattern_converter_new
                                                        (struct Log4gFormattingInfo *formatting,
                                                         gint precision);

Description

The pattern converter is an abstract class that provides the formatting functionality needed by pattern converters.

Conversion specifiers in a conversion pattern are parsed into individual pattern converters. Each pattern converter is responsible for converting a logging event in a converter-specific way.

Log4g includes the following pattern converters:

  • Basic pattern converter

  • Literal pattern converter

  • Date pattern converter

  • MDC (mapped data context) pattern converter

  • Location pattern converter

  • Logger category pattern converter

The basic pattern converter handles relative time, thread names, NDC (nested data context) values and log messages.

The literal pattern converter is used to print non-pattern text from the conversion pattern.

The date pattern converter converts a date into a string.

The MDC pattern converter handles converting MDC values.

The location pattern converter handles location information.

The logger category pattern converter handles logger names.

Details

Log4gPatternConverter

typedef struct {
} Log4gPatternConverter;

The Log4gPatternConverter structure does not have any public members.


Log4gPatternConverterClass

typedef struct {
    Log4gPatternConverterConvert convert;
    Log4gPatternConverterFormat format;
} Log4gPatternConverterClass;

Log4gPatternConverterConvert convert;

Convert a pattern.

Log4gPatternConverterFormat format;

Format in a converter specific way.

enum Log4gPatternConverterType

typedef enum {
    INVALID_CONVERTER = 0,
    RELATIVE_TIME_CONVERTER,
    THREAD_CONVERTER,
    LEVEL_CONVERTER,
    NDC_CONVERTER,
    MESSAGE_CONVERTER,
    FULL_LOCATION_CONVERTER,
    METHOD_LOCATION_CONVERTER,
    LINE_LOCATION_CONVERTER,
    FILE_LOCATION_CONVERTER,
    MAX_CONVERTER
} Log4gPatternConverterType;

INVALID_CONVERTER

Sentinel value

RELATIVE_TIME_CONVERTER

Time converter

THREAD_CONVERTER

Thread converter

LEVEL_CONVERTER

Log level converter

NDC_CONVERTER

Nested data context converter

MESSAGE_CONVERTER

Log message converter

FULL_LOCATION_CONVERTER

Log location converter

METHOD_LOCATION_CONVERTER

Function name converter

LINE_LOCATION_CONVERTER

Line number converter

FILE_LOCATION_CONVERTER

File name converter

MAX_CONVERTER

Sentinel value

log4g_pattern_converter_convert ()

const gchar *       log4g_pattern_converter_convert     (Log4gPatternConverter *self,
                                                         Log4gLoggingEvent *event);

Call the convert function from the Log4gPatternConverterClass of self.

self :

A pattern converter object.

event :

The log event to convert.

Returns :

The converted pattern.

Since 0.1


log4g_pattern_converter_format ()

void                log4g_pattern_converter_format      (Log4gPatternConverter *self,
                                                         GString *string,
                                                         Log4gLoggingEvent *event);

Call the format function from the Log4gPatternConverterClass of self.

self :

A pattern converter object.

string :

The formatted output is placed here.

event :

The log event to format.

Since 0.1


log4g_pattern_converter_get_next ()

Log4gPatternConverter * log4g_pattern_converter_get_next
                                                        (Log4gPatternConverter *self);

Retrieve the next pattern converter in the chain.

self :

A pattern converter object.

Returns :

The next pattern converter in the chain.

Since 0.1


log4g_pattern_converter_set_next ()

void                log4g_pattern_converter_set_next    (Log4gPatternConverter *self,
                                                         Log4gPatternConverter *next);

Set the next pattern converter in the chain.

self :

A pattern converter object.

next :

The next pattern converter in the chain.

Since 0.1


log4g_pattern_converter_space_pad ()

void                log4g_pattern_converter_space_pad   (const Log4gPatternConverter *self,
                                                         GString *buffer,
                                                         gint length);

A fast space padding function.

self :

A pattern converter object.

buffer :

The string to pad.

length :

The number of spaces to pad.

Since 0.1


Log4gPatternConverterConvert ()

const gchar         (*Log4gPatternConverterConvert)     (Log4gPatternConverter *self,
                                                         Log4gLoggingEvent *event);

Convert a pattern.

Derived converters must override this function in order to convert conversion specifiers in the correct way.

See: log4g/logging-event.h

self :

A pattern converter object.

event :

The log event to convert.

Returns :

The converted pattern.

Since 0.1


Log4gPatternConverterFormat ()

void                (*Log4gPatternConverterFormat)      (Log4gPatternConverter *self,
                                                         GString *string,
                                                         Log4gLoggingEvent *event);

A template function for formatting in a converter specific way.

See: log4g/logging-event.h

self :

A pattern converter object.

string :

The formatted output is placed here.

event :

The log event to format.

Since 0.1


Log4gLiteralPatternConverter

typedef struct {
} Log4gLiteralPatternConverter;

The Log4gLiteralPatternConverter structure does not have any public members.


struct Log4gLiteralPatternConverterClass

struct Log4gLiteralPatternConverterClass {
};

The Log4gLiteralPatternConverterClass structure does not have any public members.


log4g_literal_pattern_converter_new ()

Log4gPatternConverter * log4g_literal_pattern_converter_new
                                                        (const gchar *pattern);

Create a new literal pattern converter object.

pattern :

The literal text to "convert".

Returns :

A new literal pattern converter object.

Since 0.1


Log4gBasicPatternConverter

typedef struct {
} Log4gBasicPatternConverter;

The Log4gBasicPatternConverter structure does not have any public members.


struct Log4gBasicPatternConverterClass

struct Log4gBasicPatternConverterClass {
};

The Log4gBasicPatternConverterClass structure does not have any public members.


log4g_basic_pattern_converter_new ()

Log4gPatternConverter * log4g_basic_pattern_converter_new
                                                        (struct Log4gFormattingInfo *formatting,
                                                         Log4gPatternConverterType type);

Create a new basic pattern converter object.

formatting :

Formatting parameters.

type :

The type of converter to create.

Returns :

A new basic pattern converter object.

Since 0.1


Log4gDatePatternConverter

typedef struct {
} Log4gDatePatternConverter;

The Log4gDatePatternConverter structure does not have any public members.


Log4gDatePatternConverterClass

typedef struct {
} Log4gDatePatternConverterClass;

The Log4gDatePatternConverterClass structure does not have any public members.


log4g_date_pattern_converter_new ()

Log4gPatternConverter * log4g_date_pattern_converter_new
                                                        (struct Log4gFormattingInfo *formatting,
                                                         gchar *format);

Create a new date pattern converter.

See: strftime(3)

formatting :

Formatting parameters.

format :

A strfime(3) date conversion pattern.

Returns :

Create a new date pattern converter.

Since 0.1


Log4gLocationPatternConverter

typedef struct {
} Log4gLocationPatternConverter;

The Log4gLocationPatternConverter structure does not have any public members.


struct Log4gLocationPatternConverterClass

struct Log4gLocationPatternConverterClass {
};

The Log4gLocationPatternConverterClass structure does not have any public members.


log4g_location_pattern_converter_new ()

Log4gPatternConverter * log4g_location_pattern_converter_new
                                                        (struct Log4gFormattingInfo *formatting,
                                                         Log4gPatternConverterType type);

Create a new location pattern converter object.

formatting :

Formatting parameters.

type :

The type of converter to create.

Returns :

A new location pattern converter object.

Since 0.1


Log4gMDCPatternConverter

typedef struct {
} Log4gMDCPatternConverter;

The Log4gMDCPatternConverter structure does not have any public members.


Log4gMDCPatternConverterClass

typedef struct {
} Log4gMDCPatternConverterClass;

The Log4gMDCPatternConverterClass structure does not have any public members.


log4g_mdc_pattern_converter_new ()

Log4gPatternConverter * log4g_mdc_pattern_converter_new (struct Log4gFormattingInfo *formatting,
                                                         gchar *key);

Create a new MDC (mapped data context) pattern converter object.

See: Log4gMDCClass

formatting :

Formatting parameters.

key :

The MDC key to look up.

Returns :

A new MDC pattern converter object.

Since 0.1


Log4gCategoryPatternConverter

typedef struct {
} Log4gCategoryPatternConverter;

The Log4gCategoryPatternConverter structure does not have any public members.


struct Log4gCategoryPatternConverterClass

struct Log4gCategoryPatternConverterClass {
};

The Log4gCategoryPatternConverterClass structure does not have any public members.


log4g_category_pattern_converter_new ()

Log4gPatternConverter * log4g_category_pattern_converter_new
                                                        (struct Log4gFormattingInfo *formatting,
                                                         gint precision);

Create a new logger category pattern converter object.

See: Log4gLoggerClass, Log4gPatternLayoutClass

formatting :

Formatting parameters.

precision :

The logger category precision value.

Returns :

A new logger category pattern converter object.

Since 0.1

See Also

Log4gPatternLayoutClass, Log4gPatternParserClass, Log4gMDCClass, Log4gNDCClass, Log4gDateLayoutClass