Commit | Line | Data |
---|---|---|
fda777ea CH |
1 | /* |
2 | The software in this package is distributed under the GNU General | |
3 | Public License version 2 (with a special exception described below). | |
4 | ||
5 | A copy of GNU General Public License (GPL) is included in this distribution, | |
6 | in the file COPYING.GPL. | |
7 | ||
8 | As a special exception, if other files instantiate templates or use macros | |
9 | or inline functions from this file, or you compile this file and link it | |
10 | with other works to produce a work based on this file, this file | |
11 | does not by itself cause the resulting work to be covered | |
12 | by the GNU General Public License. | |
13 | ||
14 | However the source code for this file must still be made available | |
15 | in accordance with section (3) of the GNU General Public License. | |
16 | ||
17 | This exception does not invalidate any other reasons why a work based | |
18 | on this file might be covered by the GNU General Public License. | |
19 | */ | |
20 | ||
21 | #include "config/option/logfileoption.h" | |
22 | ||
23 | #include <iostream> | |
24 | ||
25 | #include <logfunc.hpp> | |
26 | ||
27 | using namespace std; | |
28 | using boost::program_options::value; | |
29 | using boost::program_options::variables_map; | |
30 | using I2n::Logger::GlobalLogger; | |
31 | ||
32 | //----------------------------------------------------------------------------- | |
33 | // LogFileOption | |
34 | //----------------------------------------------------------------------------- | |
35 | ||
36 | /** | |
37 | * @brief Default constructor. | |
38 | */ | |
39 | LogFileOption::LogFileOption() : | |
40 | ConfigurationOption( | |
41 | "log-file", | |
5e5a275f | 42 | value<string>()->default_value( "/var/log/pingcheck.log" ), |
fda777ea CH |
43 | "File to log messages to if option log-output = FILE." |
44 | ) | |
45 | { | |
46 | } | |
47 | ||
48 | /** | |
49 | * @brief Destructor. | |
50 | */ | |
51 | LogFileOption::~LogFileOption() | |
52 | { | |
53 | } | |
54 | ||
55 | bool LogFileOption::parse( | |
56 | const variables_map& vm, | |
57 | Configuration *configuration | |
58 | ) | |
59 | { | |
60 | // log-file | |
61 | if ( 1 <= vm.count( get_command_string() ) ) | |
62 | { | |
63 | string log_file = vm[ get_command_string() ].as<string> (); | |
64 | configuration->set_log_file( log_file ); | |
65 | ||
66 | GlobalLogger.info() << get_command_string() << "=" << log_file << endl; | |
67 | return true; | |
68 | } | |
69 | ||
70 | return false; | |
71 | } |