adapted eoLogger for redirecting to ostreams

This commit is contained in:
Lionel Parreaux 2013-05-06 15:27:19 +02:00 committed by LPTK
commit 146aff8a3b
3 changed files with 73 additions and 30 deletions

View file

@ -3,6 +3,10 @@
//-----------------------------------------------------------------------------
#include <eo>
//#include <paradiseo/eo.h>
#include <fstream>
#include <sstream>
#include <string>
//-----------------------------------------------------------------------------
@ -25,8 +29,24 @@ int main(int ac, char** av)
eo::log << "We are writing on the default output stream" << std::endl;
eo::log << eo::file("test.txt") << "In FILE" << std::endl;
eo::log << std::cout << "on COUT" << std::endl;
//eo::log << eo::file("test.txt") << "In FILE" << std::endl;
std::ofstream ofs("test.txt");
//eo::log << ofs << "In FILE" << std::endl;
eo::log.redirectTo(ofs);
eo::log << "In FILE" << std::endl;
std::ostringstream oss;
//eo::log << oss << "In STRINGSTREAM";
eo::log.redirectTo(oss);
eo::log << oss << "In STRINGSTREAM";
//ofs << oss;
std::cout << "Content of ostringstream: " << oss.str() << std::endl;
//eo::log << std::cout << "on COUT" << std::endl;
eo::log.redirectTo(std::cout);
eo::log << "on COUT" << std::endl;
eo::log << eo::setlevel("errors");
eo::log << eo::setlevel(eo::errors);