activemq-cpp-3.8.2
Logger.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 #ifndef _DECAF_UTIL_LOGGING_LOGGER_H_
18 #define _DECAF_UTIL_LOGGING_LOGGER_H_
19 
25 #include <decaf/util/Config.h>
26 
29 
30 #include <list>
31 #include <string>
32 #include <stdarg.h>
33 
34 namespace decaf{
35 namespace util{
36 namespace logging{
37 
38  class Filter;
39 
86  class DECAF_API Logger {
87  private:
88 
89  // The name of this Logger
90  std::string name;
91 
92  // The Parent of this Logger
93  Logger* parent;
94 
95  // list of Handlers owned by this logger
96  std::list<Handler*> handlers;
97 
98  // Filter used by this Logger
99  Filter* filter;
100 
101  // The Log Level of this Logger
102  Level level;
103 
104  // Using Parent Handlers?
105  bool useParentHandlers;
106 
107  private:
108 
109  Logger( const Logger& );
110  Logger& operator= ( const Logger& );
111 
112  protected:
113 
126  Logger( const std::string& name );
127 
128  public:
129 
130  virtual ~Logger();
131 
136  const std::string& getName() const {
137  return name;
138  }
139 
148  Logger* getParent() const {
149  return this->parent;
150  }
151 
158  void setParent( Logger* parent ) {
159  this->parent = parent;
160  }
161 
178  void addHandler( Handler* handler );
179 
188  void removeHandler( Handler* handler );
189 
195  const std::list<Handler*>& getHandlers() const;
196 
208  void setFilter( Filter* filter );
209 
214  const Filter* getFilter() const {
215  return filter;
216  }
217 
225  Level getLevel() const {
226  return level;
227  }
228 
242  void setLevel( const Level& level ) {
243  this->level = level;
244  }
245 
251  bool getUseParentHandlers() const {
252  return useParentHandlers;
253  }
254 
264  void setUseParentHandlers( bool value ) {
265  this->useParentHandlers = value;
266  }
267 
268  public: // Logging Methods.
269 
283  virtual void entering( const std::string& blockName,
284  const std::string& file,
285  const int line );
286 
300  virtual void exiting( const std::string& blockName,
301  const std::string& file,
302  const int line );
303 
319  virtual void severe( const std::string& file,
320  const int line,
321  const std::string functionName,
322  const std::string& message );
323 
339  virtual void warning( const std::string& file,
340  const int line,
341  const std::string functionName,
342  const std::string& message );
343 
359  virtual void info( const std::string& file,
360  const int line,
361  const std::string functionName,
362  const std::string& message );
363 
379  virtual void debug( const std::string& file,
380  const int line,
381  const std::string functionName,
382  const std::string& message );
383 
399  virtual void config( const std::string& file,
400  const int line,
401  const std::string functionName,
402  const std::string& message );
403 
419  virtual void fine( const std::string& file,
420  const int line,
421  const std::string functionName,
422  const std::string& message );
423 
439  virtual void finer( const std::string& file,
440  const int line,
441  const std::string functionName,
442  const std::string& message );
443 
459  virtual void finest( const std::string& file,
460  const int line,
461  const std::string functionName,
462  const std::string& message );
463 
483  virtual void throwing( const std::string& file,
484  const int line,
485  const std::string functionName,
486  const decaf::lang::Throwable& thrown );
487 
495  virtual bool isLoggable( const Level& level ) const;
496 
504  virtual void log( LogRecord& record );
505 
515  virtual void log( const Level& level, const std::string& message );
516 
529  virtual void log( const Level& levels,
530  const std::string& file,
531  const int line,
532  const std::string& message, ... );
533 
549  virtual void log( const Level& level,
550  const std::string& file,
551  const int line,
552  const std::string& message,
553  lang::Exception& ex );
554 
555  public:
556 
571  static Logger* getAnonymousLogger();
572 
588  static Logger* getLogger( const std::string& name );
589 
590  };
591 
592 }}}
593 
594 #endif /*_DECAF_UTIL_LOGGING_LOGGER_H_*/
This class represents an error that has occurred.
Definition: Throwable.h:44
The Level class defines a set of standard logging levels that can be used to control logging output...
Definition: Level.h:56
void setParent(Logger *parent)
Set the parent for this Logger.
Definition: Logger.h:158
A Logger object is used to log messages for a specific system or application component.
Definition: Logger.h:86
LogRecord objects are used to pass logging requests between the logging framework and individual log ...
Definition: LogRecord.h:41
A Filter can be used to provide fine grain control over what is logged, beyond the control provided b...
Definition: Filter.h:35
void setUseParentHandlers(bool value)
Specify whether or not this logger should send its output to it&#39;s parent Logger.
Definition: Logger.h:264
A Handler object takes log messages from a Logger and exports them.
Definition: Handler.h:49
Logger * getParent() const
Gets the parent of this Logger which will be the nearest existing Logger in this Loggers namespace...
Definition: Logger.h:148
void setLevel(const Level &level)
Set the log level specifying which message levels will be logged by this logger.
Definition: Logger.h:242
#define DECAF_API
Definition: Config.h:29
Level getLevel() const
Get the log Level that has been specified for this Logger.
Definition: Logger.h:225
bool getUseParentHandlers() const
Discover whether or not this logger is sending its output to its parent logger.
Definition: Logger.h:251
Definition: Exception.h:38
const std::string & getName() const
Gets the name of this Logger.
Definition: Logger.h:136
const Filter * getFilter() const
Gets the Filter object that this class is using.
Definition: Logger.h:214
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: AprPool.h:25