Log4g Reference Manual | ||||
---|---|---|---|---|
Top | Description |
Log4gPatternConverterLog4gPatternConverter — Provide formatting functionality for pattern converters |
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
);
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.
typedef struct { } Log4gPatternConverter;
The Log4gPatternConverter structure does not have any public members.
typedef struct { Log4gPatternConverterConvert convert; Log4gPatternConverterFormat format; } Log4gPatternConverterClass;
Log4gPatternConverterConvert |
Convert a pattern. |
Log4gPatternConverterFormat |
Format in a converter specific way. |
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;
Sentinel value | |
Time converter | |
Thread converter | |
Log level converter | |
Nested data context converter | |
Log message converter | |
Log location converter | |
Function name converter | |
Line number converter | |
File name converter | |
Sentinel value |
const gchar * log4g_pattern_converter_convert (Log4gPatternConverter *self
,Log4gLoggingEvent *event
);
Call the convert
function from the Log4gPatternConverterClass of self
.
|
A pattern converter object. |
|
The log event to convert. |
Returns : |
The converted pattern. |
Since 0.1
void log4g_pattern_converter_format (Log4gPatternConverter *self
,GString *string
,Log4gLoggingEvent *event
);
Call the format
function from the Log4gPatternConverterClass of self
.
|
A pattern converter object. |
|
The formatted output is placed here. |
|
The log event to format. |
Since 0.1
Log4gPatternConverter * log4g_pattern_converter_get_next
(Log4gPatternConverter *self
);
Retrieve the next pattern converter in the chain.
|
A pattern converter object. |
Returns : |
The next pattern converter in the chain. |
Since 0.1
void log4g_pattern_converter_set_next (Log4gPatternConverter *self
,Log4gPatternConverter *next
);
Set the next pattern converter in the chain.
|
A pattern converter object. |
|
The next pattern converter in the chain. |
Since 0.1
void log4g_pattern_converter_space_pad (const Log4gPatternConverter *self
,GString *buffer
,gint length
);
A fast space padding function.
|
A pattern converter object. |
|
The string to pad. |
|
The number of spaces to pad. |
Since 0.1
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
|
A pattern converter object. |
|
The log event to convert. |
Returns : |
The converted pattern. |
Since 0.1
void (*Log4gPatternConverterFormat) (Log4gPatternConverter *self
,GString *string
,Log4gLoggingEvent *event
);
A template function for formatting in a converter specific way.
See
: log4g/logging-event.h
|
A pattern converter object. |
|
The formatted output is placed here. |
|
The log event to format. |
Since 0.1
typedef struct { } Log4gLiteralPatternConverter;
The Log4gLiteralPatternConverter structure does not have any public members.
struct Log4gLiteralPatternConverterClass { };
The Log4gLiteralPatternConverterClass structure does not have any public members.
Log4gPatternConverter * log4g_literal_pattern_converter_new
(const gchar *pattern
);
Create a new literal pattern converter object.
|
The literal text to "convert". |
Returns : |
A new literal pattern converter object. |
Since 0.1
typedef struct { } Log4gBasicPatternConverter;
The Log4gBasicPatternConverter structure does not have any public members.
struct Log4gBasicPatternConverterClass { };
The Log4gBasicPatternConverterClass structure does not have any public members.
Log4gPatternConverter * log4g_basic_pattern_converter_new (struct Log4gFormattingInfo *formatting
,Log4gPatternConverterType type
);
Create a new basic pattern converter object.
|
Formatting parameters. |
|
The type of converter to create. |
Returns : |
A new basic pattern converter object. |
Since 0.1
typedef struct { } Log4gDatePatternConverter;
The Log4gDatePatternConverter structure does not have any public members.
typedef struct { } Log4gDatePatternConverterClass;
The Log4gDatePatternConverterClass structure does not have any public members.
Log4gPatternConverter * log4g_date_pattern_converter_new (struct Log4gFormattingInfo *formatting
,gchar *format
);
Create a new date pattern converter.
See
: strftime(3)
|
Formatting parameters. |
|
A strfime(3) date conversion pattern. |
Returns : |
Create a new date pattern converter. |
Since 0.1
typedef struct { } Log4gLocationPatternConverter;
The Log4gLocationPatternConverter structure does not have any public members.
struct Log4gLocationPatternConverterClass { };
The Log4gLocationPatternConverterClass structure does not have any public members.
Log4gPatternConverter * log4g_location_pattern_converter_new (struct Log4gFormattingInfo *formatting
,Log4gPatternConverterType type
);
Create a new location pattern converter object.
|
Formatting parameters. |
|
The type of converter to create. |
Returns : |
A new location pattern converter object. |
Since 0.1
typedef struct { } Log4gMDCPatternConverter;
The Log4gMDCPatternConverter structure does not have any public members.
typedef struct { } Log4gMDCPatternConverterClass;
The Log4gMDCPatternConverterClass structure does not have any public members.
Log4gPatternConverter * log4g_mdc_pattern_converter_new (struct Log4gFormattingInfo *formatting
,gchar *key
);
Create a new MDC (mapped data context) pattern converter object.
See
: Log4gMDCClass
|
Formatting parameters. |
|
The MDC key to look up. |
Returns : |
A new MDC pattern converter object. |
Since 0.1
typedef struct { } Log4gCategoryPatternConverter;
The Log4gCategoryPatternConverter structure does not have any public members.
struct Log4gCategoryPatternConverterClass { };
The Log4gCategoryPatternConverterClass structure does not have any public members.
Log4gPatternConverter * log4g_category_pattern_converter_new (struct Log4gFormattingInfo *formatting
,gint precision
);
Create a new logger category pattern converter object.
See
: Log4gLoggerClass, Log4gPatternLayoutClass
|
Formatting parameters. |
|
The logger category precision value. |
Returns : |
A new logger category pattern converter object. |
Since 0.1