* added some useful comments in eoLogger class
This commit is contained in:
parent
20a4496b83
commit
0834d689e8
2 changed files with 51 additions and 46 deletions
|
|
@ -50,12 +50,15 @@ eoLogger::eoLogger()
|
||||||
_standard_io_streams[&std::clog] = 2;
|
_standard_io_streams[&std::clog] = 2;
|
||||||
_standard_io_streams[&std::cerr] = 2;
|
_standard_io_streams[&std::cerr] = 2;
|
||||||
|
|
||||||
|
// /!\ If you want to add a level dont forget to add it at the header file in the enumerator Levels
|
||||||
|
|
||||||
addLevel("quiet", eo::quiet);
|
addLevel("quiet", eo::quiet);
|
||||||
addLevel("errors", eo::errors);
|
addLevel("errors", eo::errors);
|
||||||
addLevel("warnings", eo::warnings);
|
addLevel("warnings", eo::warnings);
|
||||||
addLevel("progress", eo::progress);
|
addLevel("progress", eo::progress);
|
||||||
addLevel("logging", eo::logging);
|
addLevel("logging", eo::logging);
|
||||||
addLevel("debug", eo::debug);
|
addLevel("debug", eo::debug);
|
||||||
|
addLevel("xdebug", eo::debug);
|
||||||
}
|
}
|
||||||
|
|
||||||
eoLogger::~eoLogger()
|
eoLogger::~eoLogger()
|
||||||
|
|
|
||||||
|
|
@ -20,65 +20,65 @@
|
||||||
Contact: http://eodev.sourceforge.net
|
Contact: http://eodev.sourceforge.net
|
||||||
|
|
||||||
Authors:
|
Authors:
|
||||||
Johann Dréo <johann.dreo@thalesgroup.com>
|
Johann Dréo <johann.dreo@thalesgroup.com>
|
||||||
Caner Candan <caner.candan@thalesgroup.com>
|
Caner Candan <caner.candan@thalesgroup.com>
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** Here's an example explaning how to use eoLogger:
|
/** Here's an example explaning how to use eoLogger:
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <utils/eoLogger.h>
|
#include <utils/eoLogger.h>
|
||||||
#include <utils/eoParserLogger.h>
|
#include <utils/eoParserLogger.h>
|
||||||
|
|
||||||
int main(int ac, char** av)
|
int main(int ac, char** av)
|
||||||
{
|
{
|
||||||
// We are declaring first an overload of eoParser class using Logger
|
// We are declaring first an overload of eoParser class using Logger
|
||||||
// component.
|
// component.
|
||||||
eoParserLogger parser(ac, av);
|
eoParserLogger parser(ac, av);
|
||||||
|
|
||||||
// This call is important to allow -v parameter to change user level.
|
// This call is important to allow -v parameter to change user level.
|
||||||
make_verbose(parser);
|
make_verbose(parser);
|
||||||
|
|
||||||
// At this time we are switching to warning message and messages
|
// At this time we are switching to warning message and messages
|
||||||
// which are going to follow it are going to be warnings message too.
|
// which are going to follow it are going to be warnings message too.
|
||||||
// These messages can be displayed only if the user level (sets with
|
// These messages can be displayed only if the user level (sets with
|
||||||
// eo::setlevel function) is set to eo::warnings.
|
// eo::setlevel function) is set to eo::warnings.
|
||||||
eo::log << eo::warnings;
|
eo::log << eo::warnings;
|
||||||
|
|
||||||
// With the following eo::file function we are defining that
|
// With the following eo::file function we are defining that
|
||||||
// all future logs are going to this new file resource which is
|
// all future logs are going to this new file resource which is
|
||||||
// test.txt
|
// test.txt
|
||||||
eo::log << eo::file("test.txt") << "In FILE" << std::endl;
|
eo::log << eo::file("test.txt") << "In FILE" << std::endl;
|
||||||
|
|
||||||
// Now we are changing again the resources destination to cout which
|
// Now we are changing again the resources destination to cout which
|
||||||
// is the standard output.
|
// is the standard output.
|
||||||
eo::log << std::cout << "In COUT" << std::endl;
|
eo::log << std::cout << "In COUT" << std::endl;
|
||||||
|
|
||||||
// Here are 2 differents examples of how to set the errors user level
|
// Here are 2 differents examples of how to set the errors user level
|
||||||
// in using either a string or an identifier.
|
// in using either a string or an identifier.
|
||||||
eo::log << eo::setlevel("errors");
|
eo::log << eo::setlevel("errors");
|
||||||
eo::log << eo::setlevel(eo::errors);
|
eo::log << eo::setlevel(eo::errors);
|
||||||
|
|
||||||
// Now we are writting a message, that will be displayed only if we are above the "quiet" level
|
// Now we are writting a message, that will be displayed only if we are above the "quiet" level
|
||||||
eo::log << eo::quiet << "1) Must be in quiet mode to see that" << std::endl;
|
eo::log << eo::quiet << "1) Must be in quiet mode to see that" << std::endl;
|
||||||
|
|
||||||
// And so on...
|
// And so on...
|
||||||
eo::log << eo::setlevel(eo::warnings) << eo::warnings << "2) Must be in warnings mode to see that" << std::endl;
|
eo::log << eo::setlevel(eo::warnings) << eo::warnings << "2) Must be in warnings mode to see that" << std::endl;
|
||||||
|
|
||||||
eo::log << eo::setlevel(eo::logging);
|
eo::log << eo::setlevel(eo::logging);
|
||||||
|
|
||||||
eo::log << eo::errors;
|
eo::log << eo::errors;
|
||||||
eo::log << "3) Must be in errors mode to see that";
|
eo::log << "3) Must be in errors mode to see that";
|
||||||
eo::log << std::endl;
|
eo::log << std::endl;
|
||||||
|
|
||||||
eo::log << eo::debug << 4 << ')'
|
eo::log << eo::debug << 4 << ')'
|
||||||
<< " Must be in debug mode to see that\n";
|
<< " Must be in debug mode to see that\n";
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef eoLogger_h
|
#ifndef eoLogger_h
|
||||||
# define eoLogger_h
|
# define eoLogger_h
|
||||||
|
|
@ -95,6 +95,8 @@ namespace eo
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Levels contents all the available levels in eoLogger
|
* Levels contents all the available levels in eoLogger
|
||||||
|
*
|
||||||
|
* /!\ If you want to add a level dont forget to add it at the implementation of the class eoLogger in the ctor
|
||||||
*/
|
*/
|
||||||
enum Levels {quiet = 0,
|
enum Levels {quiet = 0,
|
||||||
errors,
|
errors,
|
||||||
|
|
@ -102,16 +104,16 @@ namespace eo
|
||||||
progress,
|
progress,
|
||||||
logging,
|
logging,
|
||||||
debug,
|
debug,
|
||||||
xdebug};
|
xdebug};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* file
|
* file
|
||||||
* this structure combined with the friend operator<< below is an easy way to select a file like output.
|
* this structure combined with the friend operator<< below is an easy way to select a file as output.
|
||||||
*/
|
*/
|
||||||
struct file
|
struct file
|
||||||
{
|
{
|
||||||
file(const std::string f);
|
file(const std::string f);
|
||||||
const std::string _f;
|
const std::string _f;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -122,8 +124,8 @@ namespace eo
|
||||||
{
|
{
|
||||||
setlevel(const std::string v);
|
setlevel(const std::string v);
|
||||||
setlevel(const Levels lvl);
|
setlevel(const Levels lvl);
|
||||||
const std::string _v;
|
const std::string _v;
|
||||||
const Levels _lvl;
|
const Levels _lvl;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Reference in a new issue