22 #ifndef _LOGRECORD_HH_
23 #define _LOGRECORD_HH_
28 #include <boost/thread.hpp>
29 #include <boost/archive/iterators/base64_from_binary.hpp>
30 #include <boost/archive/iterators/insert_linebreaks.hpp>
31 #include <boost/archive/iterators/transform_width.hpp>
32 #include <boost/archive/iterators/ostream_iterator.hpp>
33 #include <boost/filesystem.hpp>
38 #define GZ_LOG_VERSION "1.0"
78 public:
bool Init(
const std::string &_subdir);
92 public:
void Add(
const std::string &_name,
const std::string &_filename,
93 boost::function<
bool (std::ostringstream &)> _logCallback);
103 public:
bool Remove(
const std::string &_name);
110 public:
void Start(
const std::string &_encoding=
"bz2");
121 private:
void Update();
132 public: Log(
LogRecord *_parent,
const std::string &_filename,
133 boost::function<
bool (std::ostringstream &)> _logCB);
135 public:
virtual ~Log();
137 public:
void Write();
139 public:
void Update();
141 public:
void ClearBuffer();
144 public: boost::function<bool (std::ostringstream &)> logCB;
145 public: std::string buffer;
146 public: std::ofstream logFile;
147 public: std::string filename;
153 private:
typedef std::map<std::string, Log*> Log_M;
159 private: Log_M::iterator updateIter;
162 private: Log_M::iterator logsEnd;
171 private: boost::thread *writeThread;
174 private: boost::mutex writeMutex;
177 private: boost::mutex controlMutex;
181 private: boost::condition_variable dataAvailableCondition;
184 private: boost::filesystem::path logPath;
187 private: std::string encoding;
190 private:
bool initialized;