akmhoque | ba09474 | 2014-02-28 11:47:21 -0600 | [diff] [blame] | 1 | #ifndef NLSR_LOGGER_HPP |
| 2 | #define NLSR_LOGGER_HPP |
| 3 | |
| 4 | #define BOOST_LOG_DYN_LINK 1 |
| 5 | |
| 6 | #include <stdexcept> |
| 7 | #include <string> |
| 8 | #include <iostream> |
| 9 | #include <sstream> |
| 10 | #include <pwd.h> |
| 11 | #include <cstdlib> |
| 12 | #include <string> |
| 13 | #include <unistd.h> |
| 14 | #include <boost/format.hpp> |
| 15 | #include <boost/smart_ptr/shared_ptr.hpp> |
| 16 | #include <boost/date_time/posix_time/posix_time.hpp> |
| 17 | #include <boost/date_time/local_time/local_time.hpp> |
| 18 | #include <boost/log/common.hpp> |
| 19 | #include <boost/log/expressions.hpp> |
| 20 | #include <boost/log/attributes.hpp> |
| 21 | #include <boost/log/sources/logger.hpp> |
| 22 | #include <boost/log/sinks/sync_frontend.hpp> |
| 23 | #include <boost/log/sinks/text_file_backend.hpp> |
| 24 | |
| 25 | namespace nlsr |
| 26 | { |
| 27 | |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame^] | 28 | namespace logging = boost::log; |
| 29 | namespace attrs = boost::log::attributes; |
| 30 | namespace src = boost::log::sources; |
| 31 | namespace sinks = boost::log::sinks; |
| 32 | namespace expr = boost::log::expressions; |
| 33 | namespace keywords = boost::log::keywords; |
akmhoque | ba09474 | 2014-02-28 11:47:21 -0600 | [diff] [blame] | 34 | |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame^] | 35 | using boost::shared_ptr; |
| 36 | using namespace std; |
akmhoque | ba09474 | 2014-02-28 11:47:21 -0600 | [diff] [blame] | 37 | |
| 38 | |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame^] | 39 | class NlsrLogger |
| 40 | { |
| 41 | public: |
| 42 | NlsrLogger() |
akmhoque | ba09474 | 2014-02-28 11:47:21 -0600 | [diff] [blame] | 43 | { |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame^] | 44 | } |
akmhoque | ba09474 | 2014-02-28 11:47:21 -0600 | [diff] [blame] | 45 | |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame^] | 46 | void initNlsrLogger(std::string dirPath); |
akmhoque | ba09474 | 2014-02-28 11:47:21 -0600 | [diff] [blame] | 47 | |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame^] | 48 | src::logger& getLogger() |
| 49 | { |
| 50 | return mLogger; |
| 51 | } |
akmhoque | ba09474 | 2014-02-28 11:47:21 -0600 | [diff] [blame] | 52 | |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame^] | 53 | private: |
| 54 | string getEpochTime(); |
| 55 | string getUserHomeDirectory(); |
akmhoque | ba09474 | 2014-02-28 11:47:21 -0600 | [diff] [blame] | 56 | |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame^] | 57 | private: |
| 58 | src::logger mLogger; |
| 59 | }; |
akmhoque | ba09474 | 2014-02-28 11:47:21 -0600 | [diff] [blame] | 60 | |
| 61 | }//namespace nlsr |
| 62 | #endif |