Apache Qpid - AMQP Messaging for Java JMS, C++, Python, Ruby, and .NET Apache Qpid Documentation
Logger.h
Go to the documentation of this file.
1 #ifndef QPID_LOG_LOGGER_H
2 #define QPID_LOG_LOGGER_H
3 
4 /*
5  * http://www.apache.org/licenses/LICENSE-2.0
6  *
7  * Unless required by applicable law or agreed to in writing, software
8  * distributed under the License is distributed on an "AS IS" BASIS,
9  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10  * See the License for the specific language governing permissions and
11  * limitations under the License.
12  *
13  */
14 
15 #include "qpid/log/Selector.h"
16 #include "qpid/log/Options.h"
17 #include "qpid/sys/Mutex.h"
18 #include <boost/ptr_container/ptr_vector.hpp>
19 #include <boost/noncopyable.hpp>
20 #include <set>
22 
23 namespace qpid {
24 namespace log {
25 
36 class QPID_COMMON_CLASS_EXTERN Logger : private boost::noncopyable {
37  public:
39  enum FormatFlag { FILE=1, LINE=2, FUNCTION=4, LEVEL=8, TIME=16, THREAD=32, HIRES=64, CATEGORY=128};
40 
50  class Output {
51  public:
53  QPID_COMMON_EXTERN virtual ~Output();
55  virtual void log(const Statement&, const std::string&) =0;
56  };
57 
58  QPID_COMMON_EXTERN static Logger& instance();
59 
62 
64  QPID_COMMON_EXTERN void select(const Selector& s);
65 
67  QPID_COMMON_EXTERN void format(int formatFlags);
68 
72  QPID_COMMON_EXTERN int format(const Options&);
73 
75  QPID_COMMON_EXTERN void configure(const Options& o);
76 
78  QPID_COMMON_EXTERN void reconfigure(const std::vector<std::string>& selectors);
79 
81  QPID_COMMON_EXTERN void add(Statement& s);
82 
84  QPID_COMMON_EXTERN void log(const Statement&, const std::string&);
85 
87  QPID_COMMON_EXTERN void output(std::auto_ptr<Output> out);
88 
90  QPID_COMMON_EXTERN void setPrefix(const std::string& prefix);
91 
93  QPID_COMMON_EXTERN void clear();
94 
96  QPID_COMMON_INLINE_EXTERN const Options& getOptions() const { return options; }
97 
99  QPID_COMMON_EXTERN bool getHiresTimestamp();
100 
102  QPID_COMMON_EXTERN void setHiresTimestamp(bool setting);
103 
104  private:
105  typedef boost::ptr_vector<Output> Outputs;
106  typedef std::set<Statement*> Statements;
107 
108  sys::Mutex lock;
109  inline void enable_unlocked(Statement* s);
110 
111  Statements statements;
112  Outputs outputs;
113  Selector selector;
114  int flags;
115  std::string prefix;
116  Options options;
117 };
118 
119 }} // namespace qpid::log
120 
121 
122 #endif
#define QPID_COMMON_EXTERN
Logging options for config parser.
Definition: Options.h:31
Logging output sink.
Definition: Logger.h:50
A selector identifies the set of log messages to enable.
Definition: Selector.h:51
This file was automatically generated from the AMQP specification.
Definition: Address.h:27
Central logging agent.
Definition: Logger.h:36
FormatFlag
Flags indicating what to include in the log output.
Definition: Logger.h:39
POD struct representing a logging statement in source code.
Definition: Statement.h:103
Mutex lock.
Definition: Mutex.h:35
#define QPID_COMMON_INLINE_EXTERN
#define QPID_COMMON_CLASS_EXTERN
QPID_COMMON_INLINE_EXTERN const Options & getOptions() const
Get the options used to configure the logger.
Definition: Logger.h:96

Qpid C++ API Reference
Generated on Tue Jan 27 2015 for Qpid C++ Client API by doxygen 1.8.9.1