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");
125 private:
void Update();
136 public: Log(
LogRecord *_parent,
const std::string &_filename,
137 boost::function<
bool (std::ostringstream &)> _logCB);
139 public:
virtual ~Log();
141 public:
void Write();
143 public:
void Update();
145 public:
void ClearBuffer();
148 public: boost::function<bool (std::ostringstream &)> logCB;
149 public: std::string buffer;
150 public: std::ofstream logFile;
151 public: std::string filename;
157 private:
typedef std::map<std::string, Log*> Log_M;
163 private: Log_M::iterator updateIter;
166 private: Log_M::iterator logsEnd;
175 private: boost::thread *writeThread;
178 private: boost::mutex writeMutex;
181 private: boost::mutex controlMutex;
185 private: boost::condition_variable dataAvailableCondition;
188 private: boost::filesystem::path logPath;
191 private: std::string encoding;
194 private:
bool initialized;