18 #ifndef _SDF_CONSOLE_HH_
19 #define _SDF_CONSOLE_HH_
25 #include <boost/shared_ptr.hpp>
33 #define sdfdbg (sdf::Console::Instance()->Log("Dbg", \
37 #define sdfmsg (sdf::Console::Instance()->ColorMsg("Msg", \
38 __FILE__, __LINE__, 32))
41 #define sdfwarn (sdf::Console::Instance()->ColorMsg("Warning", \
42 __FILE__, __LINE__, 33))
45 #define sdferr (sdf::Console::Instance()->ColorMsg("Error", \
46 __FILE__, __LINE__, 31))
64 public:
template <
class T>
68 *this->stream << _rhs;
81 public:
void Prefix(
const std::string &_lbl,
82 const std::string &_file,
83 unsigned int _line,
int _color)
85 int index = _file.find_last_of(
"/") + 1;
89 *this->stream <<
"\033[1;" << _color <<
"m" << _lbl <<
" [" <<
90 _file.substr(index , _file.size() - index)<<
":" << _line <<
97 _file.substr(index , _file.size() - index)<<
":" << _line <<
"] ";
102 private: std::ostream *stream;
112 public:
static boost::shared_ptr<Console>
Instance();
124 public: ConsoleStream &
ColorMsg(
const std::string &lbl,
125 const std::string &file,
126 unsigned int line,
int color);
130 public: ConsoleStream &
Log(
const std::string &lbl,
131 const std::string &file,
135 private: ConsoleStream msgStream;
138 private: ConsoleStream logStream;
141 private: std::ofstream logFileStream;
144 private:
static boost::shared_ptr<Console> myself;
An ostream-like class that we'll use for logging.
Definition: Console.hh:52
Message, error, warning, and logging functionality.
Definition: Console.hh:49
ConsoleStream & ColorMsg(const std::string &lbl, const std::string &file, unsigned int line, int color)
Use this to output a colored message to the terminal.
ConsoleStream & Log(const std::string &lbl, const std::string &file, unsigned int line)
Use this to output a message to a log file.
void Prefix(const std::string &_lbl, const std::string &_file, unsigned int _line, int _color)
Print a prefix to both terminal and log file.
Definition: Console.hh:81
void SetQuiet(bool _q)
Set quiet output.
ConsoleStream & operator<<(const T &_rhs)
Redirect whatever is passed in to both our ostream (if non-NULL) and the log file (if open)...
Definition: Console.hh:65
ConsoleStream(std::ostream *_stream)
Constructor.
Definition: Console.hh:57
virtual ~Console()
Destructor.
static Console * Instance()
Return an instance to this class.