22 #include "goby/common/logger.h" 23 #include <boost/asio/deadline_timer.hpp> 33 int main(
int argc,
char* argv[])
37 std::cout <<
"usage: flexostream quiet|warn|verbose|debug|gui [file.txt]" << std::endl;
49 std::string verbosity = argv[1];
61 std::cerr <<
"Could not open " << argv[2] <<
" for writing!" << std::endl;
66 if (verbosity ==
"quiet")
68 std::cout <<
"--- testing quiet ---" << std::endl;
73 else if (verbosity ==
"warn")
75 std::cout <<
"--- testing warn ---" << std::endl;
80 else if (verbosity ==
"verbose")
82 std::cout <<
"--- testing verbose ---" << std::endl;
87 else if (verbosity ==
"debug")
89 std::cout <<
"--- testing debug 1---" << std::endl;
94 else if (verbosity ==
"gui")
96 std::cout <<
"--- testing gui ---" << std::endl;
102 const int CLOSE_TIME = 60;
103 goby::glog << warn <<
"closing in " << CLOSE_TIME <<
" seconds!" << std::endl;
106 boost::asio::io_service io_service;
107 boost::asio::deadline_timer timer(io_service);
108 timer.expires_from_now(boost::posix_time::seconds(CLOSE_TIME));
113 std::cout <<
"invalid verbosity setting: " << verbosity << std::endl;
124 glog.is(WARN) &&
glog <<
"this is warning text" << std::endl;
125 glog.is(VERBOSE) &&
glog <<
"this is normal text" << std::endl;
128 glog.is(DEBUG1) &&
glog <<
"this is debug text" << std::endl;
130 glog.is(VERBOSE) &&
glog << group(
"a") <<
"this text is related to a" << std::endl;
131 glog.is(VERBOSE) &&
glog << group(
"b") <<
"this text is related to b" << std::endl;
132 glog.is(VERBOSE) &&
glog << group(
"c") << warn <<
"this warning is related to c" << std::endl;
void set_name(const std::string &s)
Set the name of the application that the logger is serving.
Contains functions for adding color to Terminal window streams.
std::ostream & lt_blue(std::ostream &os)
All text following this manipulator is light blue (e.g. std::cout << lt_blue << "text";) ...
void add_group(const std::string &name, Colors::Color color=Colors::nocolor, const std::string &description="")
Add another group to the logger. A group provides related manipulator for categorizing log messages...
common::FlexOstream glog
Access the Goby logger through this object.
Represents the eight available terminal colors (and bold variants)
void add_stream(logger::Verbosity verbosity=logger::VERBOSE, std::ostream *os=0)
Attach a stream object (e.g. std::cout, std::ofstream, ...) to the logger with desired verbosity...
std::ostream & nocolor(std::ostream &os)
All text following this manipulator is uncolored (e.g. std::cout << green << "green" << nocolor << "u...