Apache Log4cxx Version 1.1.0
|
The FMTLayout class uses libfmt to layout messages. More...
#include <fmtlayout.h>
Public Member Functions | |
FMTLayout () | |
FMTLayout (const LogString &pattern) | |
~FMTLayout () | |
void | setConversionPattern (const LogString &conversionPattern) |
Set the ConversionPattern option. | |
LogString | getConversionPattern () const |
Returns the value of the ConversionPattern option. | |
void | format (LogString &output, const spi::LoggingEventPtr &event, helpers::Pool &pool) const override |
Returns the log statement in a format consisting of the level , followed by " - " and then the message . | |
bool | ignoresThrowable () const override |
If the layout handles the throwable object contained within LoggingEvent , then the layout should return false . | |
void | activateOptions (helpers::Pool &) override |
Activate the options that were previously set with calls to option setters. | |
void | setOption (const LogString &, const LogString &) override |
Set option to value . | |
Public Member Functions inherited from log4cxx::Layout | |
virtual | ~Layout () |
virtual void | format (LogString &output, const spi::LoggingEventPtr &event, log4cxx::helpers::Pool &pool) const =0 |
Implement this method to create your own layout format. | |
virtual LogString | getContentType () const |
Returns the content type output by this layout. | |
virtual void | appendHeader (LogString &output, log4cxx::helpers::Pool &p) |
Append the header for the layout format. | |
virtual void | appendFooter (LogString &output, log4cxx::helpers::Pool &p) |
Append the footer for the layout format. | |
virtual bool | ignoresThrowable () const =0 |
If the layout handles the throwable object contained within LoggingEvent , then the layout should return false . | |
Public Member Functions inherited from log4cxx::spi::OptionHandler | |
virtual | ~OptionHandler () |
virtual void | activateOptions (helpers::Pool &p)=0 |
Activate the options that were previously set with calls to option setters. | |
virtual void | setOption (const LogString &option, const LogString &value)=0 |
Set option to value . | |
Public Member Functions inherited from log4cxx::helpers::Object | |
virtual | ~Object () |
virtual const helpers::Class & | getClass () const =0 |
virtual bool | instanceof (const Class &clazz) const =0 |
virtual const void * | cast (const Class &clazz) const =0 |
The FMTLayout class uses libfmt to layout messages.
This is an alternative to the PatternLayout class. Most of the standard PatternLayout arguments are also accepted as arguments, so that you can easily convert a PatternLayout to a FMTLayout. For example, given the following PatternLayout:
c %-5p - mn
which outputs something like:
root INFO - Hello there!
The equivalent FMTLayout can be written as:
{c} {p:<5} - {m}{n}
Or more verbosely as:
{logger} {level:<5} - {message}{newline}
All replacements are done using the named arguments feature of {fmt}.
The recognized conversion strings are:
Conversion string | Effect |
---|---|
c logger | Used to output the logger of the logging event. Unlike PatternConverter, this does not take a parameter to shorten the name of the logger. |
C class | Used to output the class of the issuer of the logging event if the compiler used supports a macro to retrieve the method of the currently compiled line and if the LOG4CXX_TRACE-like macros are used to issue a logging request. In this case the macro LOG4CXX_* is expanded at compile time to generate location info of the logging event and adds the method name, besides file and line, if available. In most cases the provided method contains the classname and can therefore be retrieved form the location info as needed. Currently supported compilers are those from Microsoft, GNU-C and Borland. |
f shortfilename | Used to output the short file name where the logging request was issued. |
F filename | Used to output the file name where the logging request was issued. |
l location | Used to output location information of the caller which generated the logging event. |
L line | Used to output the line number from where the logging request was issued. |
m message | Used to output the application supplied message associated with the logging event. |
M method | Used to output the method of the issuer of the logging event if the compiler used supports a macro to retrieve the method of the currently compiled line and if the LOG4CXX_TRACE-like macros are used to issue a logging request. In this case the macro LOG4CXX_* is expanded at compile time to generate location info of the logging event and adds the method name, besides file and line, if available. In most cases the provided method contains the classname which is ignored in every attempt to retrieve the method from the location info. Currently supported compilers are those from Microsoft, GNU-C and Borland. |
n newline | Outputs the platform dependent line separator character or characters. This conversion character offers practically the same performance as using non-portable line separator strings such as "\n", or "\r\n". Thus, it is the preferred way of specifying a line separator. |
p level | Used to output the level of the logging event. |
r | Used to output the number of milliseconds elapsed since the start of the application until the creation of the logging event. |
t thread | Used to output the ID of the thread that generated the logging event. |
T threadname | Used to output the name of the thread that generated the logging event. May not be available on all platforms. |
x ndc | Used to output the NDC (nested diagnostic context) associated with the thread that generated the logging event. |
mdc[1-6] | Used to output the MDC (mapped diagnostic context) associated with the thread that generated the logging event. The keys must be specified in the configuration for the layout. A maximum of 6 MDC keys are available to be output(mdc1, mdc2, ..., mdc6) |
log4cxx::FMTLayout::FMTLayout | ( | ) |
log4cxx::FMTLayout::FMTLayout | ( | const LogString & | pattern | ) |
log4cxx::FMTLayout::~FMTLayout | ( | ) |
|
overridevirtual |
Activate the options that were previously set with calls to option setters.
No action is performed in this implementation.
Implements log4cxx::spi::OptionHandler.
|
overridevirtual |
Returns the log statement in a format consisting of the level
, followed by " - " and then the message
.
For example,
INFO - "A message"
Implements log4cxx::Layout.
LogString log4cxx::FMTLayout::getConversionPattern | ( | ) | const |
Returns the value of the ConversionPattern option.
|
inlineoverridevirtual |
If the layout handles the throwable object contained within LoggingEvent
, then the layout should return false
.
Otherwise, if the layout ignores throwable object, then the layout should return true
.
The SimpleLayout, FMTLayout and PatternLayout return true
. The other layouts return false
.
Implements log4cxx::Layout.
void log4cxx::FMTLayout::setConversionPattern | ( | const LogString & | conversionPattern | ) |
Set the ConversionPattern option.
This is the string which controls formatting and consists of a mix of literal content and conversion specifiers.
Set option
to value
.
Supported options | Supported values | Default value |
---|---|---|
ConversionPattern | {any} | - |
Implements log4cxx::spi::OptionHandler.