OSDN Git Service

基本ファイルを追加
[winaudioj/sfwasapi.git] / sfwasapi / logger.h
1 #pragma once
2
3 #include "boost/date_time/gregorian/gregorian.hpp"
4 #include "boost/date_time/posix_time/posix_time.hpp"
5 #include "singleton.h"
6
7 namespace sf {
8
9   struct logger : public singleton<logger>
10   {
11   public:
12     logger();
13     ~logger();
14     void write(const boost::wformat & fmt);
15     void write(const std::wstring & mes);
16     void write(const TCHAR * mes);
17     void write(const std::wistream & st);
18   private:
19     struct impl;
20     boost::shared_ptr<impl> m_impl;
21   };
22
23   void debug_out(const char * file_name,const int line,boost::wformat& fmt);
24   void debug_out(const char * file_name,const int line,const std::wstring& str);
25   void debug_out(const char * file_name,const int line,const char* str);
26   void debug_out(const char * file_name,const int line,const wchar_t* str);
27 }
28
29 #define WRITE_LOG(s) \
30   sf::logger::instance()->write(boost::wformat(_T("%s %s %6d %s")) % boost::posix_time::second_clock::local_time() % (TCHAR*)sf::ca2t(__FILE__) % __LINE__ % (s))
31
32 #ifdef _DEBUG
33 #define SFTRACE(x) sf::debug_out(__FILE__,__LINE__,(x))
34 #else 
35 #define SFTRACE(x) 
36 #endif
37