Go to the documentation of this file.
25 #ifndef GOBY_UTIL_DEBUG_LOGGER_FLEX_OSTREAM_H
26 #define GOBY_UTIL_DEBUG_LOGGER_FLEX_OSTREAM_H
32 #include <google/protobuf/io/tokenizer.h>
33 #include <google/protobuf/text_format.h>
51 std::cerr <<
"Fatal error: cannot create more than one instance of FlexOstream. Use "
52 "global object goby::glog to access the Goby Logger. Do not instantiate "
53 "the FlexOstream directly."
64 const std::string& description =
"");
97 std::ostream* os =
nullptr)
119 std::ostream&
operator<<(std::ostream& (*pf)(std::ostream&));
135 std::ostream&
operator<<(std::ios_base& (*pf)(std::ios_base&))
163 bool quiet() {
return (sb_.
is_quiet()); }
173 static int instances_;
197 template <
typename _CharT,
typename _Traits,
typename _Alloc>
199 const std::basic_string<_CharT, _Traits, _Alloc>& s)
208 extern util::FlexOstream
glog;
220 : original_(original), has_warnings_(false), has_errors_(false)
224 void AddError(
int line,
int column,
const std::string& message)
override
230 << message << std::endl;
233 void AddWarning(
int line,
int column,
const std::string& message)
override
239 << message << std::endl;
241 has_warnings_ =
true;
248 std::stringstream ss(original_ +
"\n");
249 std::string line_str;
255 while (!getline(ss, line_str).eof())
259 << std::setw(3) << i++ <<
"]" << line_str
263 << line_str << std::endl;
271 const std::string& original_;
std::ostream & operator<<(const unsigned short &val)
static const Verbosity VERBOSE
Color
The eight terminal colors (and bold or "light" variants)
std::ostream & operator<<(const float &val)
bool is(goby::util::logger::Verbosity verbosity)
Forms the basis of the Goby logger: std::ostream derived class for holding the FlexOStreamBuf.
The global namespace for the Goby project.
bool is_quiet() const
do all attached streams have Verbosity == quiet?
void print_original(int line, int)
void set_group(const std::string &s)
std::ostream & operator<<(FlexOstream &(*pf)(FlexOstream &))
std::recursive_mutex mutex
~FlexOstream() override=default
std::ostream & operator<<(const unsigned long &val)
std::ostream & operator<<(const long double &val)
void name(const std::string &s)
name of the application being served
LockAction
Mutex actions available to the Goby logger (glogger)
util::FlexOstream & glogger()
void add_stream(logger::Verbosity verbosity=logger::VERBOSE, std::ostream *os=nullptr)
Attach a stream object (e.g. std::cout, std::ofstream, ...) to the logger with desired verbosity.
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.
void remove_stream(std::ostream *os=nullptr)
void refresh()
refresh the display (does nothing if !is_gui())
std::ostream & operator<<(const long long &val)
std::ostream & operator<<(const long &val)
std::recursive_mutex & mutex()
Get a reference to the Goby logger mutex for scoped locking.
std::ostream & operator<<(const short &val)
const FlexOStreamBuf & buf()
void add_stream(logger::Verbosity verbosity, std::ostream *os)
add a stream to the logger
void AddWarning(int line, int column, const std::string &message) override
void group_name(const std::string &s)
current group name (last insertion of group("") into the stream)
std::ostream & operator<<(bool &val)
std::ostream & nocolor(std::ostream &os)
All text following this manipulator is uncolored (e.g. std::cout << green << "green" << nocolor << "u...
std::ostream & operator<<(const int &val)
std::ostream & operator<<(std::streambuf *sb)
void add_stream(goby::util::protobuf::GLogConfig::Verbosity verbosity=goby::util::protobuf::GLogConfig::VERBOSE, std::ostream *os=nullptr)
void set_lock_action(logger_lock::LockAction lock_action)
FlexOStreamErrorCollector(const std::string &original)
std::ostream & operator<<(std::ios_base &(*pf)(std::ios_base &))
std::ostream & operator<<(std::ios &(*pf)(std::ios &))
util::FlexOstream glog
Access the Goby logger through this object.
std::ostream & operator<<(FlexOstream &out, char c)
std::ostream & operator<<(FlexOstream &out, const std::basic_string< _CharT, _Traits, _Alloc > &s)
std::ostream & operator<<(const unsigned int &val)
std::ostream & operator<<(const double &val)
void set_name(const std::string &s)
Set the name of the application that the logger is serving.
void AddError(int line, int column, const std::string &message) override
void set_lock_action(logger_lock::LockAction lock_action)
void remove_stream(std::ostream *os)
remove a stream from the logger
std::ostream & lt_red(std::ostream &os)
All text following this manipulator is light red (e.g. std::cout << lt_red << "text";)