X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libtest%2Fstream.h;h=9917b94df253ed0ae103e834bf0e0ae26e7f3040;hb=1be0350e7ae7a566896a9fe52863dcc22433fc8a;hp=0b503a04c6f4092ac6565eaea6de94ad1ce75b35;hpb=28602fd2f5f1c758b50cd82d4545da8e6c55f5c7;p=m6w6%2Flibmemcached diff --git a/libtest/stream.h b/libtest/stream.h index 0b503a04..9917b94d 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,37 +115,30 @@ template