This explain explain how call log functions.
#include <boost/program_options.hpp>
namespace po = boost::program_options;
{
po::options_description desc("Allowed options");
int globalVerbosity;
desc.add_options()
("help,h", "Produces help message")
("version", "Output NAOqi version.")
("verbose,v", "Set verbose verbosity.")
("debug,d", "Set debug verbosity.")
("quiet,q", "Do not show logs on console.")
("context,c", po::value<int>(), "Show context logs: [0-7] (0: none, 1: categories, 2: date, 3: file+line, 4: date+categories, 5: date+line+file, 6: categories+line+file, 7: all (date+categories+line+file+function)).")
("synchronous-log", "Activate synchronous logs.")
("log-level,L", po::value<int>(&globalVerbosity)->default_value(4), "Change the log minimum level: [0-6] (0: silent, 1: fatal, 2: error, 3: warning, 4: info, 5: verbose, 6: debug). Default: 4 (info)")
;
po::variables_map vm;
try
{
po::store(po::parse_command_line(argc, argv, desc), vm);
po::notify(vm);
}
{
std::cerr << e.what() << std::endl;
std::cout << desc << std::endl;
exit(1);
}
if (vm.count("help")) {
std::cout << desc << std::endl;
return 0;
}
if (vm.count("log-level"))
{
if (globalVerbosity > 0 && globalVerbosity <= 6)
if (globalVerbosity > 6)
if (globalVerbosity <= 0)
}
if (vm.count("quiet"))
if (vm.count("debug"))
if (vm.count("verbose"))
if (vm.count("context"))
{
int globalContext = vm["context"].as<int>();
if (globalContext < 0)
{
}
else if (globalContext > 7)
{
}
else
{
}
}
if (vm.count("synchronous-log"))
qiLogFatal(
"core.log.example.2") <<
"f" << 4 << std::endl;
qiLogError(
"core.log.example.2") <<
"e" << 4 << std::endl;
qiLogWarning(
"core.log.example.2") <<
"w" << 4 << std::endl;
qiLogInfo(
"core.log.example.2") <<
"i" << 4 << std::endl;
qiLogVerbose(
"core.log.example.2") <<
"v" << 4 << std::endl;
qiLogDebug(
"core.log.example.2") <<
"d" << 4 << std::endl;
qiLogFatal(
"core.log.example.1",
"without '\\n': %d", 41);
qiLogError(
"core.log.example.1",
"without '\\n': %d", 42);
qiLogWarning(
"core.log.example.1",
"without '\\n': %d", 43);
qiLogInfo(
"core.log.example.1",
"without '\\n': %d", 44);
qiLogVerbose(
"core.log.example.1",
"without '\\n': %d", 45);
qiLogDebug(
"core.log.example.1",
"without '\\n': %d", 46);
qiLogFatal(
"core.log.example.2") <<
"f " <<
"without '\\n'";
qiLogError(
"core.log.example.2") <<
"e " <<
"without '\\n'";
qiLogWarning(
"core.log.example.2") <<
"w " <<
"without '\\n'";
qiLogInfo(
"core.log.example.2") <<
"i " <<
"without '\\n'";
qiLogVerbose(
"core.log.example.2") <<
"v " <<
"without '\\n'";
qiLogDebug(
"core.log.example.2") <<
"d " <<
"without '\\n'";
qiLogFatal(
"core.log.example.3",
"%d", 21) <<
"f" << 4 << std::endl;
qiLogError(
"core.log.example.3",
"%d", 21) <<
"e" << 4 << std::endl;
qiLogWarning(
"core.log.example.3",
"%d", 21) <<
"w" << 4 << std::endl;
qiLogInfo(
"core.log.example.3",
"%d", 21) <<
"i" << 4 << std::endl;
qiLogVerbose(
"core.log.example.3",
"%d", 21) <<
"v" << 4 << std::endl;
qiLogDebug(
"core.log.example.3",
"%d", 21) <<
"d" << 4 << std::endl;
"Oups my buffer is too bad: %x\n",
0x0BADCAFE);
qiLogError(
"core.log.example.4") <<
"Where is nao?"
<< " - Nao is in the kitchen."
<< " - How many are they? "
<< 42 << std::endl;
qiLogInfo(
"core.log.example.4",
"%d %d ", 41, 42) << 43 <<
" " << 44
<< std::endl;
std::cout << "I've just finished to log!" << std::endl;
}