#ifndef LOGGER_HPP #define LOGGER_HPP #include #include namespace Plains { namespace Core { using std::string; using std::ofstream; //using std::ostream; //using std::streambuf; class Logger { public: enum Level { DEBUG, INFO, WARN, FATAL }; Logger(Level logLevel); ~Logger(); void setLogLevel(Level level); void log(Level lvl, const char* msg); void log(Level lvl, const string& msg); static const char commit = 0; class Sink { private: bool lineIsPrefixed_; Logger& parent_; const Logger::Level level_; void prefixLine(bool resetToFalse = false); public: Sink(const Level level, Logger& parent); void ln (const string& msg); void ln (const char* msg); Sink& operator<<(const char character); Sink& operator<<(const string& msg); Sink& operator<<(const char* msg); Sink& operator<<(const long msg); Sink& operator<<(const unsigned long msg); }; Sink debug; Sink info; Sink warn; Sink fatal; private: enum Level logLevel; ofstream* output; static string genTimeStamp(); }; }} #endif