/usr/include/log4shib/CategoryStream.hh is in liblog4shib-dev 1.0.9-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | /*
* CategoryStream.hh
*
* Copyright 2001, LifeLine Networks BV (www.lifeline.nl). All rights reserved.
* Copyright 2001, Bastiaan Bakker. All rights reserved.
*
* See the COPYING file for the terms of usage and distribution.
*/
#ifndef _LOG4SHIB_CATEGORYSTREAM_HH
#define _LOG4SHIB_CATEGORYSTREAM_HH
#include <log4shib/Portability.hh>
#include <log4shib/Priority.hh>
#ifdef LOG4SHIB_HAVE_SSTREAM
#include <sstream>
#endif
namespace log4shib {
class LOG4SHIB_EXPORT Category;
class LOG4SHIB_EXPORT CategoryStream;
/**
* eol manipulator
**/
LOG4SHIB_EXPORT CategoryStream& eol (CategoryStream& os);
/**
* This class enables streaming simple types and objects to a category.
* Use category.errorStream(), etc. to obtain a CategoryStream class.
**/
class LOG4SHIB_EXPORT CategoryStream {
public:
/**
* Construct a CategoryStream for given Category with given priority.
* @param category The category this stream will send log messages to.
* @param priority The priority the log messages will get or
* Priority::NOTSET to silently discard any streamed in messages.
**/
CategoryStream(Category& category, Priority::Value priority);
/**
* Destructor for CategoryStream
**/
~CategoryStream();
/**
* Returns the destination Category for this stream.
* @returns The Category.
**/
inline Category& getCategory() const { return _category; };
/**
* Returns the priority for this stream.
* @returns The priority.
**/
inline Priority::Value getPriority() const throw() {
return _priority;
};
/**
* Flush the contents of the stream buffer to the Category and
* empties the buffer.
**/
void flush();
/**
* Stream in arbitrary types and objects.
* @param t The value or object to stream in.
* @returns A reference to itself.
**/
template<typename T> CategoryStream& operator<<(const T& t) {
if (getPriority() != Priority::NOTSET) {
if (!_buffer) {
if (!(_buffer = new std::ostringstream)) {
// XXX help help help
}
}
(*_buffer) << t;
}
return *this;
}
private:
Category& _category;
Priority::Value _priority;
std::ostringstream* _buffer;
public:
typedef CategoryStream& (*cspf) (CategoryStream&);
CategoryStream& operator << (cspf);
LOG4SHIB_EXPORT friend CategoryStream& eol (CategoryStream& os);
};
}
#endif // _LOG4SHIB_CATEGORYSTREAM_HH
|