X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libtest%2Fstream.h;h=081c2bf04ef26685677d58af17a448f95071025d;hb=d169e8c62f8ca4fe7d058d8e2254426105032b7e;hp=0b503a04c6f4092ac6565eaea6de94ad1ce75b35;hpb=28602fd2f5f1c758b50cd82d4545da8e6c55f5c7;p=awesomized%2Flibmemcached diff --git a/libtest/stream.h b/libtest/stream.h index 0b503a04..081c2bf0 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,66 @@ namespace stream { namespace detail { template - class 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 << s.str() << std::endl; - } - }; - -template - class make_cerr { - private: - - public: - typedef std::basic_ostringstream stream_buffer; - - public: - void operator()(const stream_buffer &s) - { - std::cerr << std::endl << s.str() << std::endl; - } - }; - -template - class cout { - private: - - public: - typedef std::basic_ostringstream stream_buffer; - - public: - void operator()(const stream_buffer &s) - { - std::cout << s.str() << std::endl; + if (filename) + { + _out + << filename + << ":" + << line_number + << ": in " + << func << "() " + << s.str() + << std::endl; + } + else + { + _out + << s.str() + << std::endl; + } } }; template - class clog { + 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::cerr<< 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; + } } }; @@ -107,72 +115,96 @@ template