}
};
+template<class Ch, class Tr, class A>
+ class channelfl {
+ private:
+
+ public:
+ typedef std::basic_ostringstream<Ch, Tr, A> stream_buffer;
+
+ public:
+ void operator()(const stream_buffer& s, std::ostream& _out,
+ const char* filename, int line_number, const char* func)
+ {
+ if (filename)
+ {
+ _out
+ << filename
+ << ":"
+ << line_number
+ << ": in "
+ << func << "() "
+ << s.str()
+ << std::flush;
+ }
+ else
+ {
+ _out
+ << s.str()
+ << std::flush;
+ }
+ }
+ };
+
template<template <class Ch, class Tr, class A> class OutputPolicy, class Ch = char, class Tr = std::char_traits<Ch>, class A = std::allocator<Ch> >
class log {
private:
_func(func)
{ }
- ~log()
+ virtual ~log()
{
output_policy()(arg, _out, _filename, _line_number, _func);
}
private:
typename output_policy::stream_buffer arg;
+
+ private:
+ log( const log& );
+ const log& operator=( const log& );
};
} // namespace detail
detail::log<detail::channelln>(std::cerr, filename, line_number, func)
{ }
+private:
+ make_cerr( const make_cerr& );
+ const make_cerr& operator=( const make_cerr& );
};
class cerr : public detail::log<detail::channel> {
detail::log<detail::channel>(std::cout, filename, line_number, func)
{ }
+private:
+ cerr( const cerr& );
+ const cerr& operator=( const cerr& );
};
class clog : public detail::log<detail::channel> {
clog(const char* filename, int line_number, const char* func) :
detail::log<detail::channel>(std::clog, filename, line_number, func)
{ }
+
+private:
+ clog( const clog& );
+ const clog& operator=( const clog& );
+};
+
+class make_cout : public detail::log<detail::channelln> {
+public:
+ make_cout(const char* filename, int line_number, const char* func) :
+ detail::log<detail::channelln>(std::cout, filename, line_number, func)
+ { }
+
+private:
+ make_cout( const make_cout& );
+ const make_cout& operator=( const make_cout& );
};
class cout : public detail::log<detail::channel> {
cout(const char* filename, int line_number, const char* func) :
detail::log<detail::channel>(std::cout, filename, line_number, func)
{ }
+
+private:
+ cout( const cout& );
+ const cout& operator=( const cout& );
};
+class cecho : public detail::log<detail::channelfl> {
+public:
+ cecho(const char* filename, int line_number, const char* func) :
+ detail::log<detail::channelfl>(std::cout, filename, line_number, func)
+ { }
+
+private:
+ cecho( const cecho& );
+ const cecho& operator=( const cecho& );
+};
} // namespace stream
#define Error stream::cerr(__FILE__, __LINE__, __func__)
+#define Echo stream::cecho(NULL, __LINE__, __func__)
+
#define Out stream::cout(NULL, __LINE__, __func__)
#define Outn() stream::cout(NULL, __LINE__, __func__) << " "