SUNphi  1.0
SUNphi::Logger Class Reference

Write output to a file, using different level of indentation. More...

#include <Logger.hpp>

Inheritance diagram for SUNphi::Logger:
SUNphi::File

Classes

class  LoggerLine
 Single line in the logger. More...
 

Public Member Functions

void indentMore ()
 Increase indentation.
 
void indentLess ()
 Decrease indentation.
 
LoggerLine getNewLine ()
 Create a new line.
 
LoggerLine operator() ()
 Create a new line.
 
LoggerLine printVariadicMessage (const char *format, va_list ap)
 Print a C-style variadic message. More...
 
 Logger (const char *path, const bool &prependTime=true)
 Create with a path. More...
 

Public Attributes

bool onlyMasterThreadPrint {true}
 Decide whether only master thread can write here.
 
bool onlyMasterRankPrint {true}
 Decide whether only master MPI can write here.
 

Private Types

enum  RealFormat { GENERAL =0, FIXED =1, ENGINEER =2 }
 Print mode for double/float.
 

Private Member Functions

const Filefile () const
 Access to the logger as if it was a file.
 
template<typename... Ts>
decltype(auto) file (Ts &&...ts)
 
void getExclusiveAccess ()
 Set the exclusive access right.
 
void releaseExclusiveAccess ()
 Release the exclusive access right.
 
void open (const char *path, const char *mode, const bool crashIfFail=true)
 Open a file, crashing if impossible. More...
 
bool isOpen () const
 Check if open.
 
void close ()
 Close.
 
int getRc () const
 Returns rc.
 
Fileoperator<< (const char &c)
 Prints a char. More...
 
Fileoperator<< (const int32_t &i)
 Prints an integer. More...
 
Fileoperator<< (const uint32_t &i)
 Prints an unsigned integer. More...
 
Fileoperator<< (const int64_t &l)
 Prints a long integer. More...
 
Fileoperator<< (const uint64_t &l)
 Prints a long unsigned integer. More...
 
Fileoperator<< (const double &d)
 Prints a double. More...
 
template<typename T >
Fileoperator<< (const T *p)
 Prints a pointer. More...
 
Fileoperator<< (const char *str)
 Prints a string.
 
Fileoperator<< (const std::string &str)
 Prints a c++ string.
 
template<typename T >
Fileoperator* (T &&t)
 Prints after putting a space. More...
 

Private Attributes

int indentLev {0}
 Indentation level.
 
bool prependTime
 Determine wheter the new line includes time.
 
Mutex mutex
 Mutex used to lock the logger.
 
int realPrecision {6}
 Precision to print real number.
 
bool alwaysPrintSign {false}
 Flag to determine whether print always or not the sign.
 
bool alwaysPrintZero {false}
 Flag to determine whether print always or not the zero.
 
RealFormat realFormat {RealFormat::GENERAL}
 Format mode for real number.
 

Static Private Attributes

static Logger fakeLogger
 Fake logger, printing to /dev/null.
 

Detailed Description

Write output to a file, using different level of indentation.

Definition at line 35 of file Logger.hpp.

Constructor & Destructor Documentation

SUNphi::Logger::Logger ( const char *  path,
const bool &  prependTime = true 
)
inline

Create with a path.

Parameters
pathPath to open
prependTimePrepend or not with time

Definition at line 394 of file Logger.hpp.

Member Function Documentation

template<typename... Ts>
decltype(auto) SUNphi::Logger::file ( Ts &&...  ts)
inlineprivate

Overload the file const method passing all args

Parameters
tsArguments

Definition at line 49 of file Logger.hpp.

void SUNphi::File::open ( const char *  path,
const char *  mode,
const bool  crashIfFail = true 
)
inlineinherited

Open a file, crashing if impossible.

Parameters
pathPath to open
modeMode used to open
crashIfFailCrash or not if failing

Definition at line 90 of file File.hpp.

template<typename T >
File& SUNphi::File::operator* ( T &&  t)
inlineinherited

Prints after putting a space.

Parameters
tObject to be printed

Definition at line 235 of file File.hpp.

File& SUNphi::File::operator<< ( const char &  c)
inlineinherited

Prints a char.

Parameters
cChar to write

Definition at line 152 of file File.hpp.

File& SUNphi::File::operator<< ( const int32_t &  i)
inlineinherited

Prints an integer.

Parameters
iInteger to write

Definition at line 163 of file File.hpp.

File& SUNphi::File::operator<< ( const uint32_t &  i)
inlineinherited

Prints an unsigned integer.

Parameters
iUnsigned integer to write

Definition at line 173 of file File.hpp.

File& SUNphi::File::operator<< ( const int64_t &  l)
inlineinherited

Prints a long integer.

Parameters
lLong integer to write

Definition at line 183 of file File.hpp.

File& SUNphi::File::operator<< ( const uint64_t &  l)
inlineinherited

Prints a long unsigned integer.

Parameters
lLong unsigned integer to write

Definition at line 193 of file File.hpp.

File& SUNphi::File::operator<< ( const double &  d)
inlineinherited

Prints a double.

String to print real numbers

The first component is signed or not The second component is the format

Definition at line 203 of file File.hpp.

template<typename T >
File& SUNphi::File::operator<< ( const T *  p)
inlineinherited

Prints a pointer.

Parameters
pPointer to be printed

Definition at line 224 of file File.hpp.

LoggerLine SUNphi::Logger::printVariadicMessage ( const char *  format,
va_list  ap 
)
inline

Print a C-style variadic message.

Parameters
formatFormat to print
apVariadic part

Definition at line 386 of file Logger.hpp.


The documentation for this class was generated from the following files: