log4cplus  2.1.0
tracelogger.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 // Module: Log4CPLUS
3 // File: tracelogger.h
4 // Created: 1/2009
5 // Author: Vaclav Haisman
6 //
7 //
8 // Copyright 2009-2017 Tad E. Smith
9 //
10 // Licensed under the Apache License, Version 2.0 (the "License");
11 // you may not use this file except in compliance with the License.
12 // You may obtain a copy of the License at
13 //
14 // http://www.apache.org/licenses/LICENSE-2.0
15 //
16 // Unless required by applicable law or agreed to in writing, software
17 // distributed under the License is distributed on an "AS IS" BASIS,
18 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 // See the License for the specific language governing permissions and
20 // limitations under the License.
21 
24 #ifndef LOG4CPLUS_TRACELOGGER_H
25 #define LOG4CPLUS_TRACELOGGER_H
26 
27 #include <log4cplus/config.hxx>
28 
29 #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
30 #pragma once
31 #endif
32 
33 #include <log4cplus/logger.h>
34 
35 
36 namespace log4cplus
37 {
38 
39 
51 {
52 public:
54  const char* _file = LOG4CPLUS_CALLER_FILE (),
55  int _line = LOG4CPLUS_CALLER_LINE (),
56  char const * _function = LOG4CPLUS_CALLER_FUNCTION ())
57  : logger(std::move (l)), msg(std::move (_msg)), file(_file),
58  function(_function), line(_line)
59  {
60  if(logger.isEnabledFor(TRACE_LOG_LEVEL))
61  logger.forcedLog(TRACE_LOG_LEVEL, LOG4CPLUS_TEXT("ENTER: ") + msg,
62  file, line, function);
63  }
64 
66  {
67  if(logger.isEnabledFor(TRACE_LOG_LEVEL))
68  logger.forcedLog(TRACE_LOG_LEVEL, LOG4CPLUS_TEXT("EXIT: ") + msg,
69  file, line, function);
70  }
71 
72 private:
73  TraceLogger (TraceLogger const &);
74  TraceLogger & operator = (TraceLogger const &);
75 
76  Logger logger;
78  const char* file;
79  const char* function;
80  int line;
81 };
82 
83 
84 } // log4cplus
85 
86 
87 #endif // LOG4CPLUS_TRACELOGGER_H
This is the central class in the log4cplus package.
Definition: logger.h:71
bool isEnabledFor(LogLevel ll) const
Check whether this logger is enabled for a given LogLevel passed as parameter.
void forcedLog(LogLevel ll, const log4cplus::tstring &message, const char *file=LOG4CPLUS_CALLER_FILE(), int line=LOG4CPLUS_CALLER_LINE(), const char *function=LOG4CPLUS_CALLER_FUNCTION()) const
This method creates a new logging event and logs the event without further checks.
This class is used to produce "Trace" logging.
Definition: tracelogger.h:51
TraceLogger(Logger l, log4cplus::tstring _msg, const char *_file=LOG4CPLUS_CALLER_FILE(), int _line=LOG4CPLUS_CALLER_LINE(), char const *_function=LOG4CPLUS_CALLER_FUNCTION())
Definition: tracelogger.h:53
#define LOG4CPLUS_TEXT(STRING)
Definition: clogger.h:72
#define LOG4CPLUS_CALLER_FUNCTION()
Definition: config.hxx:123
#define LOG4CPLUS_CALLER_FILE()
Definition: config.hxx:121
#define LOG4CPLUS_CALLER_LINE()
Definition: config.hxx:122
This header defines the Logger class and the logging macros.
std::basic_string< tchar > tstring
Definition: tstring.h:39
const LogLevel TRACE_LOG_LEVEL
The TRACE_LOG_LEVEL LogLevel is used to "trace" entry and exiting of methods.
Definition: loglevel.h:84