eo::log: added the parameter -o in order to define a log file + removed some warning messages at compile time
This commit is contained in:
parent
0834d689e8
commit
5bd0baace7
4 changed files with 46 additions and 9 deletions
|
|
@ -17,8 +17,8 @@
|
|||
Contact: http://eodev.sourceforge.net
|
||||
|
||||
Authors:
|
||||
Johann Dreo <johann.dreo@thalesgroup.com>
|
||||
Caner Candan <caner.candan@thalesgroup.com>
|
||||
Johann Dreo <johann.dreo@thalesgroup.com>
|
||||
Caner Candan <caner.candan@thalesgroup.com>
|
||||
|
||||
*/
|
||||
|
||||
|
|
@ -30,16 +30,44 @@ eoParserLogger::eoParserLogger(unsigned _argc, char** _argv,
|
|||
std::string _lFileParamName /*= "param-file"*/,
|
||||
char _shortHand /*= 'p'*/)
|
||||
: eoParser(_argc, _argv, _programDescription, _lFileParamName, _shortHand),
|
||||
_verbose("quiet", "verbose", "Set the verbose level", 'v'),
|
||||
_printVerboseLevels(false, "print-verbose-levels", "Print verbose levels", 'l')
|
||||
_verbose("quiet", "verbose", "Set the verbose level", 'v'),
|
||||
_printVerboseLevels(false, "print-verbose-levels", "Print verbose levels", 'l'),
|
||||
_output("", "output", "Redirect a standard output to a file", 'o')
|
||||
{
|
||||
//------------------------------------------------------------------
|
||||
// we are saying to eoParser to create the parameters created above.
|
||||
//------------------------------------------------------------------
|
||||
|
||||
processParam(_verbose);
|
||||
processParam(_printVerboseLevels);
|
||||
processParam(_output);
|
||||
|
||||
if (!_printVerboseLevels.value())
|
||||
return;
|
||||
//------------------------------------------------------------------
|
||||
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// we're gonna redirect the log to the given filename if -o is used.
|
||||
//------------------------------------------------------------------
|
||||
|
||||
if ( ! _output.value().empty() )
|
||||
{
|
||||
eo::log << eo::file( _output.value() );
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// // we're gonna print the list of levels if -l parameter is used.
|
||||
//------------------------------------------------------------------
|
||||
|
||||
if ( _printVerboseLevels.value() )
|
||||
{
|
||||
eo::log.printLevels();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
|
||||
eo::log.printLevels();
|
||||
}
|
||||
|
||||
eoParserLogger::~eoParserLogger()
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ private:
|
|||
friend void make_verbose(eoParserLogger&);
|
||||
eoValueParam<std::string> _verbose;
|
||||
eoValueParam<bool> _printVerboseLevels;
|
||||
eoValueParam<std::string> _output;
|
||||
};
|
||||
|
||||
void make_verbose(eoParserLogger&);
|
||||
|
|
|
|||
|
|
@ -90,14 +90,16 @@ bool testDirRes(std::string _dirName, bool _erase=true)
|
|||
if (res) // no dir present
|
||||
{
|
||||
s = string("mkdir ")+ _dirName;
|
||||
system(s.c_str());
|
||||
int res = system(s.c_str());
|
||||
(void)res;
|
||||
return true;
|
||||
}
|
||||
// else
|
||||
if (_erase) // OK to erase
|
||||
{
|
||||
s = string("/bin/rm ")+ _dirName + "/*";
|
||||
system(s.c_str());
|
||||
int res = system(s.c_str());
|
||||
(void)res;
|
||||
return true;
|
||||
}
|
||||
//else
|
||||
|
|
|
|||
|
|
@ -6,18 +6,24 @@
|
|||
#include <utils/eoLogger.h>
|
||||
#include <utils/eoParserLogger.h>
|
||||
|
||||
#include <eo>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int main(int ac, char** av)
|
||||
{
|
||||
eoParserLogger parser(ac, av);
|
||||
|
||||
make_help(parser);
|
||||
|
||||
make_verbose(parser);
|
||||
|
||||
eo::log << eo::setlevel(eo::debug);
|
||||
|
||||
eo::log << eo::warnings;
|
||||
|
||||
eo::log << "We are written on the default defined standard output" << std::endl;
|
||||
|
||||
eo::log << eo::file("test.txt") << "In FILE" << std::endl;
|
||||
eo::log << std::cout << "In COUT" << std::endl;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue