debug messages to log file
This commit is contained in:
11
main.cpp
11
main.cpp
@@ -42,7 +42,7 @@ namespace po = boost::program_options;
|
||||
|
||||
typedef vector< string > split_vector_type;
|
||||
|
||||
static void init_log(void)
|
||||
static void init_log(bool debug = false)
|
||||
{
|
||||
/* init boost log
|
||||
* 1. Add common attributes
|
||||
@@ -89,6 +89,10 @@ static void init_log(void)
|
||||
boost::log::keywords::min_free_space = 30 * 1024 * 1024,
|
||||
boost::log::keywords::open_mode = std::ios_base::app);
|
||||
fsSink->set_formatter(logFmt);
|
||||
if (!debug)
|
||||
fsSink->set_filter(
|
||||
boost::log::trivial::severity >= boost::log::trivial::warning
|
||||
);
|
||||
fsSink->locked_backend()->auto_flush(true);
|
||||
}
|
||||
|
||||
@@ -110,12 +114,11 @@ int main(int argc, char* argv[])
|
||||
std::string port,path,filename;
|
||||
int speed;
|
||||
|
||||
init_log();
|
||||
|
||||
po::options_description desc("Allowed options");
|
||||
desc.add_options()
|
||||
("help", "produce help message")
|
||||
("measure", "get and print values")
|
||||
("debug", "debug output to file")
|
||||
("verbose", po::value<string>()->implicit_value("0"), "verbosity level")
|
||||
("file", po::value<string>(&filename)->default_value("camera.jpg"),"filename of capture filename")
|
||||
("path", po::value<string>(&path)->default_value("/tmp"),"directory for file of capture")
|
||||
@@ -139,6 +142,8 @@ int main(int argc, char* argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
init_log(vm.count("debug"));
|
||||
|
||||
} catch(std::exception& e) {
|
||||
cerr << "error: " << e.what() << "\n";
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user