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