log4shib 2.0.1
Loading...
Searching...
No Matches
CategoryStream.hh
Go to the documentation of this file.
1/*
2 * CategoryStream.hh
3 *
4 * Copyright 2001, LifeLine Networks BV (www.lifeline.nl). All rights reserved.
5 * Copyright 2001, Bastiaan Bakker. All rights reserved.
6 *
7 * See the COPYING file for the terms of usage and distribution.
8 */
9
10#ifndef _LOG4SHIB_CATEGORYSTREAM_HH
11#define _LOG4SHIB_CATEGORYSTREAM_HH
12
14#include <log4shib/Priority.hh>
15#ifdef LOG4SHIB_HAVE_SSTREAM
16#include <sstream>
17#endif
18
19namespace log4shib {
20
23
28
34 public:
35
42 CategoryStream(Category& category, Priority::Value priority);
43
48
53 inline Category& getCategory() const { return _category; };
54
59 inline Priority::Value getPriority() const throw() {
60 return _priority;
61 };
62
67 void flush();
68
74 template<typename T> CategoryStream& operator<<(const T& t) {
76 if (!_buffer) {
77 if (!(_buffer = new std::ostringstream)) {
78 // XXX help help help
79 }
80 }
81 (*_buffer) << t;
82 }
83 return *this;
84 }
85
86 private:
87 Category& _category;
88 Priority::Value _priority;
89 std::ostringstream* _buffer;
90
91 public:
92 typedef CategoryStream& (*cspf) (CategoryStream&);
93 CategoryStream& operator << (cspf);
95 };
96
97}
98#endif // _LOG4SHIB_CATEGORYSTREAM_HH
#define LOG4SHIB_EXPORT
Definition Export.hh:11
This class enables streaming simple types and objects to a category.
Definition CategoryStream.hh:33
CategoryStream &(* cspf)(CategoryStream &)
Definition CategoryStream.hh:92
CategoryStream & operator<<(const T &t)
Stream in arbitrary types and objects.
Definition CategoryStream.hh:74
Priority::Value getPriority() const
Returns the priority for this stream.
Definition CategoryStream.hh:59
Category & getCategory() const
Returns the destination Category for this stream.
Definition CategoryStream.hh:53
CategoryStream(Category &category, Priority::Value priority)
Construct a CategoryStream for given Category with given priority.
Definition CategoryStream.cpp:21
LOG4SHIB_EXPORT friend CategoryStream & eol(CategoryStream &os)
eol manipulator
Definition CategoryStream.cpp:43
This is the central class in the log4j package.
Definition Category.hh:32
@ NOTSET
Definition Priority.hh:78
int Value
The type of Priority Values.
Definition Priority.hh:84
Definition Portability.hh:38
The top level namespace for all 'Log for C++' types and classes.
Definition AbortAppender.hh:16
LOG4SHIB_EXPORT CategoryStream & eol(CategoryStream &os)
eol manipulator
Definition CategoryStream.cpp:43