// -*- C++ -*-
// Module: Log4CPLUS
// File: Layout.h
// Created: 6/2001
// Author: Tad E. Smith
//
//
// Copyright 2001-2010 Tad E. Smith
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/** @file */
#ifndef DCMTK_LOG4CPLUS_LAYOUT_HEADER_
#define DCMTK_LOG4CPLUS_LAYOUT_HEADER_
#include "dcmtk/oflog/config.h"
#if defined (DCMTK_LOG4CPLUS_HAVE_PRAGMA_ONCE)
#pragma once
#endif
#include "dcmtk/oflog/loglevel.h"
#include "dcmtk/oflog/streams.h"
#include "dcmtk/oflog/tstring.h"
#include "dcmtk/ofstd/ofvector.h"
namespace dcmtk {
namespace log4cplus {
// Forward Declarations
namespace pattern
{
class PatternConverter;
}
namespace helpers
{
class Properties;
class Time;
}
namespace spi
{
class InternalLoggingEvent;
}
/**
* This class is used to layout strings sent to an {@link
* log4cplus::Appender}.
*/
class DCMTK_LOG4CPLUS_EXPORT Layout
{
public:
Layout();
Layout(const helpers::Properties& properties);
virtual ~Layout() = 0;
virtual void formatAndAppend(log4cplus::tostream& output,
const log4cplus::spi::InternalLoggingEvent& event) = 0;
protected:
LogLevelManager& llmCache;
private:
// Disable copy
Layout(const Layout&);
Layout& operator=(Layout const &);
};
/**
* SimpleLayout consists of the LogLevel of the log statement,
* followed by " - " and then the log message itself. For example,
*
*
*
* Conversion Character |
* Effect |
*
*
*
* b |
*
* Used to output file name component of path name.
* E.g. main.cxx from path ../../main.cxx. |
*
*
*
* c |
*
* Used to output the logger of the logging event. The
* logger conversion specifier can be optionally followed by
* precision specifier, that is a decimal constant in
* brackets.
*
* If a precision specifier is given, then only the corresponding
* number of right most components of the logger name will be
* printed. By default the logger name is printed in full.
*
* For example, for the logger name "a.b.c" the pattern
* %c{2} will output "b.c".
*
* |
*
*
*
* d |
*
* Used to output the date of the logging event in UTC.
*
* The date conversion specifier may be followed by a date format
* specifier enclosed between braces. For example, %%d{%%H:%%M:%%s}
* or %%d{%%d %%b %%Y %%H:%%M:%%s}. If no date format
* specifier is given then %%d{%%d %%m %%Y %%H:%%M:%%s}
* is assumed.
*
* The Following format options are possible:
*
* - %%a -- Abbreviated weekday name
* - %%A -- Full weekday name
* - %%b -- Abbreviated month name
* - %%B -- Full month name
* - %%c -- Standard date and time string
* - %%d -- Day of month as a decimal(1-31)
* - %%H -- Hour(0-23)
* - %%I -- Hour(1-12)
* - %%j -- Day of year as a decimal(1-366)
* - %%m -- Month as decimal(1-12)
* - %%M -- Minute as decimal(0-59)
* - %%p -- Locale's equivalent of AM or PM
* - %%q -- milliseconds as decimal(0-999) -- Log4CPLUS specific
*
- %%Q -- fractional milliseconds as decimal(0-999.999) -- Log4CPLUS specific
*
- %%S -- Second as decimal(0-59)
* - %%U -- Week of year, Sunday being first day(0-53)
* - %%w -- Weekday as a decimal(0-6, Sunday being 0)
* - %%W -- Week of year, Monday being first day(0-53)
* - %%x -- Standard date string
* - %%X -- Standard time string
* - %%y -- Year in decimal without century(0-99)
* - %%Y -- Year including century as decimal
* - %%Z -- Time zone name
* - %% -- The percent sign
*
*
* Lookup the documentation for the strftime() function
* found in the <ctime> header for more information.
* |
*
*
*
* D |
*
* Used to output the date of the logging event in local time.
*
* All of the above information applies.
* |
*
*
*
* F |
*
* Used to output the file name where the logging request was
* issued.
*
* NOTE Unlike log4j, there is no performance penalty for
* calling this method. |
*
*
*
* h |
*
* Used to output the hostname of this system (as returned
* by gethostname(2)).
*
* NOTE The hostname is only retrieved once at
* initialization.
*
* |
*
*
*
* H |
*
* Used to output the fully-qualified domain name of this
* system (as returned by gethostbyname(2) for the hostname
* returned by gethostname(2)).
*
* NOTE The hostname is only retrieved once at
* initialization.
*
* |
*
*
*
* l |
*
* Equivalent to using "%F:%L"
*
* NOTE: Unlike log4j, there is no performance penalty for
* calling this method.
*
* |
*
*
*
* L |
*
* Used to output the line number from where the logging request
* was issued.
*
* NOTE: Unlike log4j, there is no performance penalty for
* calling this method.
*
* |
*
*
* m |
* Used to output the application supplied message associated with
* the logging event. |
*
*
*
* M |
*
* Used to output function name using
* __FUNCTION__ or similar macro.
*
* NOTE The __FUNCTION__ macro is not
* standard but it is common extension provided by all compilers
* (as of 2010). In case it is missing or in case this feature
* is disabled using the
* DCMTK_LOG4CPLUS_DISABLE_FUNCTION_MACRO macro, %M
* expands to an empty string. |
*
*
*
* n |
*
* Outputs the platform dependent line separator character or
* characters.
* |
*
*
* p |
* Used to output the LogLevel of the logging event. |
*
*
*
* P |
* Used to output the first character of the LogLevel of the logging event.
* NOTE: This pattern has been added to log4cplus.
* |
*
*
*
* r |
* Used to output miliseconds since program start
* of the logging event. |
*
*
*
* t |
*
* Used to output the name of the thread that generated the
* logging event. |
*
*
*
* T |
*
* Used to output alternative name of the thread that generated the
* logging event. |
*
*
*
* i |
*
* Used to output the process ID of the process that generated the
* logging event. |
*
*
*
* x |
*
* Used to output the NDC (nested diagnostic context) associated
* with the thread that generated the logging event.
* |
*
*
*
* "%%" |
* The sequence "%%" outputs a single percent sign.
* |
*
*
*
*
* By default the relevant information is output as is. However,
* with the aid of format modifiers it is possible to change the
* minimum field width, the maximum field width and justification.
*
* The optional format modifier is placed between the percent sign
* and the conversion character.
*
* The first optional format modifier is the