X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libtest%2Fstream.h;h=0124b9d256d0242f2c9fb6038771b2c19e18ad22;hb=50532bea9eb770554e1e962d03b868987303acbe;hp=558b2790b53c3360a3a03ad1d3260d7c5ad2f62a;hpb=9cd57ce737375540f6c3b5e2e3684160e5c4bfce;p=awesomized%2Flibmemcached diff --git a/libtest/stream.h b/libtest/stream.h index 558b2790..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,44 +48,97 @@ 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 << 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; + } } }; @@ -93,73 +146,121 @@ template