X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;ds=sidebyside;f=libtest%2Fstream.h;h=0124b9d256d0242f2c9fb6038771b2c19e18ad22;hb=2eb14a59f3626073017de925929dcc7e3e9eb43d;hp=ed5a03e541ed0e6090a9a6711c87132dc6dbe1e8;hpb=4429c4e4315bfeb2bdfc59c3b39f8964f68524ef;p=awesomized%2Flibmemcached diff --git a/libtest/stream.h b/libtest/stream.h index ed5a03e5..0124b9d2 100644 --- a/libtest/stream.h +++ b/libtest/stream.h @@ -1,8 +1,8 @@ /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * uTest, libtest * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Data Differential YATL (i.e. libtest) library + * + * Copyright (C) 2012 Data Differential, http://datadifferential.com/ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -48,58 +48,97 @@ namespace stream { namespace detail { template - class cerr { - private: - - public: - typedef std::basic_ostringstream stream_buffer; - - public: - void operator()(const stream_buffer &s) - { - std::cerr << s.str() << std::endl; - } - }; - -template - class make_cerr { + class channel { private: public: typedef std::basic_ostringstream stream_buffer; public: - void operator()(const stream_buffer &s) + void operator()(const stream_buffer& s, std::ostream& _out, + const char* filename, int line_number, const char* func) { - std::cerr << std::endl << s.str() << std::endl; + if (filename) + { + _out + << filename + << ":" + << line_number + << ": in " + << func << "() " + << s.str() + << std::endl; + } + else + { + _out + << s.str() + << std::endl; + } } }; template - class cout { + class channelln { private: public: typedef std::basic_ostringstream stream_buffer; public: - void operator()(const stream_buffer &s) + void operator()(const stream_buffer& s, std::ostream& _out, + const char* filename, int line_number, const char* func) { - std::cout << s.str() << std::endl; + if (filename) + { + _out + << std::endl + << filename + << ":" + << line_number + << ": in " + << func << "() " + << s.str() + << std::endl; + } + else + { + _out + << std::endl + << s.str() + << std::endl; + } } }; template - class clog { + class channelfl { private: public: typedef std::basic_ostringstream stream_buffer; public: - void operator()(const stream_buffer &s) + void operator()(const stream_buffer& s, std::ostream& _out, + const char* filename, int line_number, const char* func) { - std::cerr<< s.str() << std::endl; + if (filename) + { + _out + << filename + << ":" + << line_number + << ": in " + << func << "() " + << s.str() + << std::flush; + } + else + { + _out + << s.str() + << std::flush; + } } }; @@ -107,79 +146,115 @@ template