23 #include "goby/common/logger/flex_ostream.h" 24 #include "goby/common/exception.h" 25 #include "logger_manipulators.h" 37 int goby::common::FlexOstream::instances_ = 0;
43 const std::string& description )
46 boost::recursive_mutex::scoped_lock l(goby::common::logger::mutex);
48 if (description.empty())
50 Group ng(name, name, color);
51 sb_.add_group(name, ng);
55 Group ng(name, description, color);
56 sb_.add_group(name, ng);
66 std::ostream& goby::common::FlexOstream::operator<<(std::ostream& (*pf)(std::ostream&))
69 sb_.set_die_flag(
true);
70 set_unset_verbosity();
71 return std::ostream::operator<<(pf);
74 bool goby::common::FlexOstream::is(logger::Verbosity verbosity)
76 assert(sb_.verbosity_depth() == logger::UNKNOWN || lock_action_ != logger_lock::lock);
78 bool display = (sb_.highest_verbosity() >= verbosity) || (verbosity == logger::DIE);
82 if (sb_.lock_action() == logger_lock::lock)
84 goby::common::logger::mutex.lock();
87 sb_.set_verbosity_depth(verbosity);
92 case WARN: *
this << warn;
break;
94 case VERBOSE: *
this << verbose;
break;
95 case DEBUG1: *
this << debug1;
break;
96 case DEBUG2: *
this << debug2;
break;
97 case DEBUG3: *
this << debug3;
break;
98 case DIE: *
this << die;
break;
Forms the basis of the Goby logger: std::ostream derived class for holding the FlexOStreamBuf.
Color
The eight terminal colors (and bold or "light" variants)
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.
static std::string esc_code_from_col(const Colors::Color &c)
Escape code from color enumeration (e.g. red -> "\33[31m")
Defines a group of messages to be sent to the Goby logger. For Verbosity == verbose streams...