activemq-cpp-3.9.5
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
34namespace decaf{
35namespace util{
36namespace 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
530 virtual void log( const Level& levels,
531 const std::string& file,
532 const int line,
533 const std::string& message, ... );
534
550 virtual void log( const Level& level,
551 const std::string& file,
552 const int line,
553 const std::string& message,
554 lang::Exception& ex );
555
556 public:
557
572 static Logger* getAnonymousLogger();
573
589 static Logger* getLogger( const std::string& name );
590
591 };
592
593}}}
594
595#endif /*_DECAF_UTIL_LOGGING_LOGGER_H_*/
Definition Exception.h:38
This class represents an error that has occurred.
Definition Throwable.h:44
A Filter can be used to provide fine grain control over what is logged, beyond the control provided b...
Definition Filter.h:35
A Handler object takes log messages from a Logger and exports them.
Definition Handler.h:49
The Level class defines a set of standard logging levels that can be used to control logging output.
Definition Level.h:56
LogRecord objects are used to pass logging requests between the logging framework and individual log ...
Definition LogRecord.h:41
virtual void log(LogRecord &record)
Log a LogRecord.
void setParent(Logger *parent)
Set the parent for this Logger.
Definition Logger.h:158
virtual void throwing(const std::string &file, const int line, const std::string functionName, const decaf::lang::Throwable &thrown)
Log throwing an exception.
virtual void fine(const std::string &file, const int line, const std::string functionName, const std::string &message)
Log a FINE Level Log.
Logger(const std::string &name)
Creates a new instance of the Logger with the given name.
void setUseParentHandlers(bool value)
Specify whether or not this logger should send its output to it's parent Logger.
Definition Logger.h:264
virtual void debug(const std::string &file, const int line, const std::string functionName, const std::string &message)
Log a DEBUG Level Log.
virtual void log(const Level &level, const std::string &message)
Log a message, with no arguments.
virtual bool isLoggable(const Level &level) const
Check if a message of the given level would actually be logged by this logger.
const std::string & getName() const
Gets the name of this Logger.
Definition Logger.h:136
virtual void finer(const std::string &file, const int line, const std::string functionName, const std::string &message)
Log a FINER Level Log.
const std::list< Handler * > & getHandlers() const
Gets a vector containing all the handlers that this class has been assigned to use.
static Logger * getAnonymousLogger()
Creates an anonymous logger.
const Filter * getFilter() const
Gets the Filter object that this class is using.
Definition Logger.h:214
void removeHandler(Handler *handler)
Removes the specified Handler from this logger, ownership of the Handler pointer is returned to the c...
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
void addHandler(Handler *handler)
Add a log Handler to receive logging messages.
virtual void log(const Level &level, const std::string &file, const int line, const std::string &message, lang::Exception &ex)
Log a message, with associated Throwable information.
virtual void config(const std::string &file, const int line, const std::string functionName, const std::string &message)
Log a CONFIG Level Log.
virtual void info(const std::string &file, const int line, const std::string functionName, const std::string &message)
Log a INFO Level Log.
virtual void finest(const std::string &file, const int line, const std::string functionName, const std::string &message)
Log a FINEST Level Log.
void setFilter(Filter *filter)
Set a filter to control output on this Logger.
virtual void exiting(const std::string &blockName, const std::string &file, const int line)
Logs an Block Exit message.
Logger * getParent() const
Gets the parent of this Logger which will be the nearest existing Logger in this Loggers namespace.
Definition Logger.h:148
virtual void severe(const std::string &file, const int line, const std::string functionName, const std::string &message)
Log a SEVERE Level Log.
static Logger * getLogger(const std::string &name)
Find or create a logger for a named subsystem.
virtual void entering(const std::string &blockName, const std::string &file, const int line)
Logs an Block Enter message.
virtual void log(const Level &levels, const std::string &file, const int line, const std::string &message,...)
Log a message, with the list of params that is formatted into the message string.
virtual void warning(const std::string &file, const int line, const std::string functionName, const std::string &message)
Log a WARN Level Log.
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
Definition ConsoleHandler.h:28
Definition AbstractCollection.h:33
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition AprPool.h:25