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>
39 #define GZ_LOG_VERSION "1.0"
79 public:
bool Init(
const std::string &_subdir);
93 public:
void Add(
const std::string &_name,
const std::string &_filename,
94 boost::function<
bool (std::ostringstream &)> _logCallback);
104 public:
bool Remove(
const std::string &_name);
126 public:
bool Start(
const std::string &_encoding=
"bz2");
136 public: std::string
GetFilename(
const std::string &_name)
const;
141 public:
unsigned int GetFileSize(
const std::string &_name)
const;
145 public:
void SetBasePath(
const std::string &_path);
172 private:
void ClearLogs();
186 public: Log(
LogRecord *_parent,
const std::string &_relativeFilename,
187 boost::function<
bool (std::ostringstream &)> _logCB);
190 public:
virtual ~Log();
194 public:
void Start(
const boost::filesystem::path &_path);
197 public:
void Write();
201 public:
unsigned int Update();
204 public:
void ClearBuffer();
208 public:
unsigned int GetBufferSize();
213 public: std::string GetRelativeFilename()
const;
217 public: std::string GetCompleteFilename()
const;
223 public: boost::function<bool (std::ostringstream &)> logCB;
226 public: std::string buffer;
229 public: std::ofstream logFile;
232 public: std::string relativeFilename;
234 private: boost::filesystem::path completePath;
240 private:
typedef std::map<std::string, Log*> Log_M;
246 private: Log_M::iterator updateIter;
249 private: Log_M::iterator logsEnd;
255 private:
bool running;
258 private: boost::thread *writeThread;
261 private:
mutable boost::mutex writeMutex;
264 private: boost::mutex controlMutex;
268 private: boost::condition_variable dataAvailableCondition;
271 private: boost::filesystem::path logBasePath;
274 private: boost::filesystem::path logCompletePath;
278 private: std::string logSubDir;
281 private: std::string encoding;
284 private:
bool initialized;
287 private:
bool paused;
290 private:
bool firstUpdate;
293 private:
bool stopThread;