diff --git a/main.cpp b/main.cpp index 96328ca..ca5e4ea 100755 --- a/main.cpp +++ b/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()->implicit_value("0"), "verbosity level") ("file", po::value(&filename)->default_value("camera.jpg"),"filename of capture filename") ("path", po::value(&path)->default_value("/tmp"),"directory for file of capture") @@ -138,7 +141,9 @@ int main(int argc, char* argv[]) cout << desc << "\n"; return 0; } - + + init_log(vm.count("debug")); + } catch(std::exception& e) { cerr << "error: " << e.what() << "\n"; return 1;