Apache log4cxx  Version 0.13.0
datelayout.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef _LOG4CXX_HELPERS_DATE_LAYOUT_H
19 #define _LOG4CXX_HELPERS_DATE_LAYOUT_H
20 
21 #include <log4cxx/layout.h>
24 
25 #if defined(_MSC_VER)
26  #pragma warning ( push )
27  #pragma warning ( disable: 4251 )
28 #endif
29 
30 namespace log4cxx
31 {
32 namespace helpers
33 {
38 class LOG4CXX_EXPORT DateLayout : public Layout
39 {
40  private:
41  LogString timeZoneID;
42  LogString dateFormatOption;
43 
44  protected:
45  DateFormatPtr dateFormat;
46 
47  public:
48  DateLayout(const LogString& dateLayoutOption);
49  virtual ~DateLayout();
50 
51  virtual void activateOptions(log4cxx::helpers::Pool& p);
52  virtual void setOption(const LogString& option, const LogString& value);
53 
60  inline void setDateFormat(const LogString& dateFormat1)
61  {
62  this->dateFormatOption.assign(dateFormat1);
63  }
64 
68  inline const LogString& getDateFormat() const
69  {
70  return dateFormatOption;
71  }
72 
77  inline void setTimeZone(const LogString& timeZone)
78  {
79  this->timeZoneID.assign(timeZone);
80  }
81 
85  inline const LogString& getTimeZone() const
86  {
87  return timeZoneID;
88  }
89 
90  void formatDate(LogString& s,
91  const spi::LoggingEventPtr& event,
92  log4cxx::helpers::Pool& p) const;
93 
94  private:
95  //
96  // prevent copy and assignment
97  DateLayout(const DateLayout&);
98  DateLayout& operator=(const DateLayout&);
99 
100 };
101 } // namespace helpers
102 } // namespace log4cxx
103 
104 #if defined(_MSC_VER)
105  #pragma warning (pop)
106 #endif
107 
108 #endif // _LOG4CXX_HELPERS_DATE_LAYOUT_H
std::shared_ptr< LoggingEvent > LoggingEventPtr
Definition: appender.h:37
Extend this abstract class to create your own log layout format.
Definition: layout.h:37
const LogString & getTimeZone() const
Returns value of the TimeZone option.
Definition: datelayout.h:85
This abstract layout takes care of all the date related options and formatting work.
Definition: datelayout.h:38
DateFormatPtr dateFormat
Definition: datelayout.h:45
void setDateFormat(const LogString &dateFormat1)
The value of the DateFormat option should be either an argument to the constructor of helpers::DateFo...
Definition: datelayout.h:60
Definition: pool.h:32
const LogString & getDateFormat() const
Returns value of the DateFormat option.
Definition: datelayout.h:68
Definition: appender.h:32
std::basic_string< logchar > LogString
Definition: logstring.h:66
void setTimeZone(const LogString &timeZone)
The TimeZoneID option is a time zone ID string in the format expected by the locale C++ standard clas...
Definition: datelayout.h:77