Note: Goby version 1 (shown here) is now considered obsolete. Please use version 2 for new projects, and consider upgrading old projects.

Goby Underwater Autonomy Project  Series: 1.1, revision: 163, released on 2013-02-06 14:23:27 -0500
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
Public Member Functions | Friends
goby::util::FlexOstream Class Reference

Forms the basis of the Goby logger: std::ostream derived class for holding the FlexOStreamBuf. More...

#include <util/liblogger/flex_ostream.h>

Inherits std::ostream.

List of all members.

Public Member Functions

void refresh ()
void set_group (const std::string &s)
Initialization
void add_group (const std::string &name, Colors::Color color=Colors::nocolor, const std::string &description="")
void set_name (const std::string &s)
 Set the name of the application that the logger is serving.
void add_stream (const std::string &verbosity, std::ostream *os=0)
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.
Overloaded insert stream operator<<
std::ostream & operator<< (FlexOstream &(*pf)(FlexOstream &))
std::ostream & operator<< (std::ostream &(*pf)(std::ostream &))
std::ostream & operator<< (bool &val)
std::ostream & operator<< (const short &val)
std::ostream & operator<< (const unsigned short &val)
std::ostream & operator<< (const int &val)
std::ostream & operator<< (const unsigned int &val)
std::ostream & operator<< (const long &val)
std::ostream & operator<< (const unsigned long &val)
std::ostream & operator<< (const float &val)
std::ostream & operator<< (const double &val)
std::ostream & operator<< (const long double &val)
std::ostream & operator<< (std::streambuf *sb)
std::ostream & operator<< (std::ios &(*pf)(std::ios &))
std::ostream & operator<< (std::ios_base &(*pf)(std::ios_base &))
Thread safety related
boost::mutex & mutex ()
 Get a reference to the Goby logger mutex for scoped locking.

Friends

FlexOstreamglogger (logger_lock::LockAction lock_action)
 Access the Goby logger through this function.
template<typename T >
void boost::checked_delete (T *)
std::ostream & operator<< (FlexOstream &out, char c)
std::ostream & operator<< (FlexOstream &out, signed char c)
std::ostream & operator<< (FlexOstream &out, unsigned char c)
std::ostream & operator<< (FlexOstream &out, const char *s)
std::ostream & operator<< (FlexOstream &out, const signed char *s)
std::ostream & operator<< (FlexOstream &out, const unsigned char *s)

Detailed Description

Forms the basis of the Goby logger: std::ostream derived class for holding the FlexOStreamBuf.

Definition at line 45 of file flex_ostream.h.


Member Function Documentation

void goby::util::FlexOstream::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. For thread safe use use boost::scoped_lock on Logger::mutex

Definition at line 36 of file flex_ostream.cpp.


Friends And Related Function Documentation

FlexOstream& glogger ( logger_lock::LockAction  lock_action) [friend]

Access the Goby logger through this function.

For normal (non thread safe use), do not pass any parameters: glogger() << "some text" << std::endl;

To group messages, pass the group(group_name) manipulator, where group_name is a previously defined group (by call to glogger().add_group(Group)). For example: glogger() << group("incoming") << "received message foo" << std::endl;

For thread safe use, use glogger(lock) and then insert the "unlock" manipulator when relinquishing the lock. The "unlock" manipulator MUST be inserted before the next call to glogger(lock). Nothing must throw exceptions between glogger(lock) and unlock. For example: glogger(lock) << "my thread is the best" << std::endl << unlock;

Parameters:
lock_actionlogger_lock::lock to lock access to the logger (for thread safety) or logger_lock::none for no mutex action (typical)
Returns:
reference to Goby logger (std::ostream derived class FlexOstream)

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends