* eoLogger.h: indentation
This commit is contained in:
parent
10ef92ed60
commit
e103f4f29e
1 changed files with 30 additions and 33 deletions
|
|
@ -40,7 +40,7 @@ Caner Candan <caner.candan@thalesgroup.com>
|
||||||
{
|
{
|
||||||
// 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);
|
||||||
|
|
@ -98,7 +98,7 @@ Caner Candan <caner.candan@thalesgroup.com>
|
||||||
# include "eoObject.h"
|
# include "eoObject.h"
|
||||||
|
|
||||||
|
|
||||||
namespace eo
|
namespace eo
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Levels contents all the available levels in eoLogger
|
* Levels contents all the available levels in eoLogger
|
||||||
|
|
@ -117,7 +117,7 @@ namespace eo
|
||||||
* file
|
* file
|
||||||
* this structure combined with the friend operator<< below is an easy way to select a file as 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;
|
||||||
|
|
@ -127,7 +127,7 @@ namespace eo
|
||||||
* setlevel
|
* setlevel
|
||||||
* this structure combined with the friend operator<< below is an easy way to set a verbose level.
|
* this structure combined with the friend operator<< below is an easy way to set a verbose level.
|
||||||
*/
|
*/
|
||||||
struct setlevel
|
struct setlevel
|
||||||
{
|
{
|
||||||
setlevel(const std::string v);
|
setlevel(const std::string v);
|
||||||
setlevel(const Levels lvl);
|
setlevel(const Levels lvl);
|
||||||
|
|
@ -141,14 +141,14 @@ namespace eo
|
||||||
* Class providing a verbose management through EO
|
* Class providing a verbose management through EO
|
||||||
* Use of a global variable eo::log to easily use the logger like std::cout
|
* Use of a global variable eo::log to easily use the logger like std::cout
|
||||||
*/
|
*/
|
||||||
class eoLogger : public eoObject,
|
class eoLogger : public eoObject,
|
||||||
public std::ostream
|
public std::ostream
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
eoLogger();
|
eoLogger();
|
||||||
~eoLogger();
|
~eoLogger();
|
||||||
|
|
||||||
virtual std::string className() const;
|
virtual std::string className() const;
|
||||||
|
|
||||||
//! Print the available levels on the standard output
|
//! Print the available levels on the standard output
|
||||||
void printLevels() const;
|
void printLevels() const;
|
||||||
|
|
@ -158,107 +158,104 @@ public:
|
||||||
* Use this function if you want to be able to compare selected levels to a given one, like:
|
* Use this function if you want to be able to compare selected levels to a given one, like:
|
||||||
* if( eo::log.getLevelSelected() >= eo::progress ) {...}
|
* if( eo::log.getLevelSelected() >= eo::progress ) {...}
|
||||||
*/
|
*/
|
||||||
eo::Levels getLevelSelected() const { return _selectedLevel; }
|
inline eo::Levels getLevelSelected() const { return _selectedLevel; }
|
||||||
|
|
||||||
/*! Returns the current level of the context
|
/*! Returns the current level of the context
|
||||||
* the one given when you output message with the logger
|
* the one given when you output message with the logger
|
||||||
*/
|
*/
|
||||||
eo::Levels getLevelContext() const { return _contextLevel; }
|
inline eo::Levels getLevelContext() const { return _contextLevel; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void addLevel(std::string name, eo::Levels level);
|
void addLevel(std::string name, eo::Levels level);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* outbuf
|
* outbuf
|
||||||
* this class inherits from std::streambuf which is used by eoLogger to write the buffer in an output stream
|
* this class inherits from std::streambuf which is used by eoLogger to write the buffer in an output stream
|
||||||
*/
|
*/
|
||||||
class outbuf : public std::streambuf
|
class outbuf : public std::streambuf
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
outbuf(const int& fd,
|
outbuf(const int& fd, const eo::Levels& contexlvl, const eo::Levels& selectedlvl);
|
||||||
const eo::Levels& contexlvl,
|
|
||||||
const eo::Levels& selectedlvl);
|
|
||||||
protected:
|
protected:
|
||||||
virtual int overflow(int_type c);
|
virtual int overflow(int_type c);
|
||||||
private:
|
private:
|
||||||
const int& _fd;
|
const int& _fd;
|
||||||
const eo::Levels& _contextLevel;
|
const eo::Levels& _contextLevel;
|
||||||
const eo::Levels& _selectedLevel;
|
const eo::Levels& _selectedLevel;
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* MapLevel is the type used by the map member _levels.
|
* MapLevel is the type used by the map member _levels.
|
||||||
*/
|
*/
|
||||||
typedef std::map<std::string, eo::Levels> MapLevel;
|
typedef std::map<std::string, eo::Levels> MapLevel;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* operator<< used there to set a verbose mode.
|
* operator<< used there to set a verbose mode.
|
||||||
*/
|
*/
|
||||||
friend eoLogger& operator<<(eoLogger&, const eo::Levels);
|
friend eoLogger& operator<<(eoLogger&, const eo::Levels);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* operator<< used there to set a filename through the class file.
|
* operator<< used there to set a filename through the class file.
|
||||||
*/
|
*/
|
||||||
friend eoLogger& operator<<(eoLogger&, eo::file);
|
friend eoLogger& operator<<(eoLogger&, eo::file);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* operator<< used there to set a verbose level through the class setlevel.
|
* operator<< used there to set a verbose level through the class setlevel.
|
||||||
*/
|
*/
|
||||||
friend eoLogger& operator<<(eoLogger&, eo::setlevel);
|
friend eoLogger& operator<<(eoLogger&, eo::setlevel);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* operator<< used there to be able to use std::cout to say that we wish to redirect back the buffer to a standard output.
|
* operator<< used there to be able to use std::cout to say that we wish to redirect back the buffer to a standard output.
|
||||||
*/
|
*/
|
||||||
friend eoLogger& operator<<(eoLogger&, std::ostream&);
|
friend eoLogger& operator<<(eoLogger&, std::ostream&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* _selectedLevel is the member storing verbose level setted by the user thanks to operator()
|
* _selectedLevel is the member storing verbose level setted by the user thanks to operator()
|
||||||
*/
|
*/
|
||||||
eo::Levels _selectedLevel;
|
eo::Levels _selectedLevel;
|
||||||
eo::Levels _contextLevel;
|
eo::Levels _contextLevel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* _fd in storing the file descriptor at this place we can disable easily the buffer in
|
* _fd in storing the file descriptor at this place we can disable easily the buffer in
|
||||||
* changing the value at -1. It is used by operator <<.
|
* changing the value at -1. It is used by operator <<.
|
||||||
*/
|
*/
|
||||||
int _fd;
|
int _fd;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* _obuf std::ostream mandates to use a buffer. _obuf is a outbuf inheriting of std::streambuf.
|
* _obuf std::ostream mandates to use a buffer. _obuf is a outbuf inheriting of std::streambuf.
|
||||||
*/
|
*/
|
||||||
outbuf _obuf;
|
outbuf _obuf;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* _levels contains all the existing level order by position
|
* _levels contains all the existing level order by position
|
||||||
*/
|
*/
|
||||||
MapLevel _levels;
|
MapLevel _levels;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* _levelsOrder is just a list to keep the order of levels
|
* _levelsOrder is just a list to keep the order of levels
|
||||||
*/
|
*/
|
||||||
std::vector<std::string> _sortedLevels;
|
std::vector<std::string> _sortedLevels;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* _standard_io_streams
|
* _standard_io_streams
|
||||||
*/
|
*/
|
||||||
std::map< std::ostream*, int > _standard_io_streams;
|
std::map< std::ostream*, int > _standard_io_streams;
|
||||||
};
|
};
|
||||||
/** @example t-eoLogger.cpp
|
/** @example t-eoLogger.cpp
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace eo
|
namespace eo
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* log is an external global variable defined to easily use a same way than std::cout to write a log.
|
* log is an external global variable defined to easily use a same way than std::cout to write a log.
|
||||||
*/
|
*/
|
||||||
extern eoLogger log;
|
extern eoLogger log;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
#endif // !eoLogger_h
|
#endif // !eoLogger_h
|
||||||
|
|
|
||||||
Reference in a new issue