OFFIS DCMTK  Version 3.6.0
logevent.h
Go to the documentation of this file.
1 // Module: Log4CPLUS
2 // File: loggingevent.h
3 // Created: 6/2001
4 // Author: Tad E. Smith
5 //
6 //
7 // Copyright 2001-2009 Tad E. Smith
8 //
9 // Licensed under the Apache License, Version 2.0 (the "License");
10 // you may not use this file except in compliance with the License.
11 // You may obtain a copy of the License at
12 //
13 // http://www.apache.org/licenses/LICENSE-2.0
14 //
15 // Unless required by applicable law or agreed to in writing, software
16 // distributed under the License is distributed on an "AS IS" BASIS,
17 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 // See the License for the specific language governing permissions and
19 // limitations under the License.
20 
23 #ifndef _LOG4CPLUS_SPI_INTERNAL_LOGGING_EVENT_HEADER_
24 #define _LOG4CPLUS_SPI_INTERNAL_LOGGING_EVENT_HEADER_
25 
26 #include "dcmtk/oflog/config.h"
27 #include "dcmtk/oflog/loglevel.h"
28 #include "dcmtk/oflog/ndc.h"
29 #include "dcmtk/oflog/tstring.h"
32 
33 #include "dcmtk/ofstd/ofaptr.h"
34 
35 namespace log4cplus {
36  namespace spi {
45  class LOG4CPLUS_EXPORT InternalLoggingEvent {
46  public:
47  // Ctors
61  LogLevel ll_,
62  const log4cplus::tstring& message_,
63  const char* filename,
64  int line_,
65  const char* function_)
66  : message(message_),
67  loggerName(logger),
68  ll(ll_),
69  ndc(),
70  thread(),
71  timestamp(log4cplus::helpers::Time::gettimeofday()),
72  file( ( filename
73  ? LOG4CPLUS_C_STR_TO_TSTRING(filename)
74  : log4cplus::tstring()) ),
75  line(line_),
76  function( ( function_
77  ? LOG4CPLUS_C_STR_TO_TSTRING(function_)
78  : log4cplus::tstring()) ),
79  threadCached(false),
80  ndcCached(false)
81  {
82  }
83 
85  LogLevel ll_,
86  const log4cplus::tstring& ndc_,
87  const log4cplus::tstring& message_,
88  const log4cplus::tstring& thread_,
90  const log4cplus::tstring& file_,
91  int line_,
92  const log4cplus::tstring& function_)
93  : message(message_),
94  loggerName(logger),
95  ll(ll_),
96  ndc(ndc_),
97  thread(thread_),
98  timestamp(time),
99  file(file_),
100  line(line_),
101  function(function_),
102  threadCached(true),
103  ndcCached(true)
104  {
105  }
106 
107  InternalLoggingEvent(const log4cplus::spi::InternalLoggingEvent& rhs)
108  : message(rhs.getMessage()),
109  loggerName(rhs.getLoggerName()),
110  ll(rhs.getLogLevel()),
111  ndc(rhs.getNDC()),
112  thread(rhs.getThread()),
113  timestamp(rhs.getTimestamp()),
114  file(rhs.getFile()),
115  line(rhs.getLine()),
116  function(rhs.getFunction()),
117  threadCached(true),
118  ndcCached(true)
119  {
120  }
121 
122  virtual ~InternalLoggingEvent();
123 
124 
125  // public virtual methods
127  virtual const log4cplus::tstring& getMessage() const;
128 
133  virtual unsigned int getType() const;
134 
138  virtual OFauto_ptr<InternalLoggingEvent> clone() const;
139 
140 
141 
142  // public methods
146  const log4cplus::tstring& getLoggerName() const { return loggerName; }
147 
149  LogLevel getLogLevel() const { return ll; }
150 
152  const log4cplus::tstring& getNDC() const {
153  if(!ndcCached) {
154  ndc = log4cplus::getNDC().get();
155  ndcCached = true;
156  }
157  return ndc;
158  }
159 
161  const log4cplus::tstring& getThread() const {
162  if(!threadCached) {
163  thread = LOG4CPLUS_GET_CURRENT_THREAD_NAME;
164  threadCached = true;
165  }
166  return thread;
167  }
168 
171  const log4cplus::helpers::Time& getTimestamp() const { return timestamp; }
172 
174  const log4cplus::tstring& getFile() const { return file; }
175 
177  int getLine() const { return line; }
178 
180  const log4cplus::tstring& getFunction() const { return function; }
181 
182  // public operators
184  operator=(const log4cplus::spi::InternalLoggingEvent& rhs);
185 
186  // static methods
187  static unsigned int getDefaultType();
188 
189  protected:
190  // Data
191  log4cplus::tstring message;
192 
193  private:
194  log4cplus::tstring loggerName;
195  LogLevel ll;
196  mutable log4cplus::tstring ndc;
197  mutable log4cplus::tstring thread;
198  log4cplus::helpers::Time timestamp;
199  log4cplus::tstring file;
200  int line;
201  log4cplus::tstring function;
203  mutable bool threadCached;
205  mutable bool ndcCached;
206  };
207 
208  } // end namespace spi
209 } // end namespace log4cplus
210 
211 #endif // _LOG4CPLUS_SPI_INTERNAL_LOGGING_EVENT_HEADER_


Generated on Thu Dec 20 2012 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.8.2