TRF Language Model
wb::Log Class Reference

this class can output to the cmd window and log files simultaneously. In wb-log.cpp, there are a Log variable "lout", which can be directly used just like "cout". For example: More...

#include <wb-log.h>

Public Member Functions

 Log ()
 constructor More...
 
 ~Log ()
 destructor More...
 
void ReFile (const char *path, bool bNew=true)
 relocate the log file. The defualt log file is "program name".log More...
 
bool & bOutputCmd ()
 if output to the cmd window More...
 
bool & bOutputLog ()
 if output to the log file More...
 
template<typename T >
Logoutput (T *pArray, int n, const char *pgap=" ")
 output an array More...
 
void LevelDown ()
 level down More...
 
void LevelUp ()
 level up More...
 
void Progress (long long n=-1, bool bInit=false, long long total=100, const char *head="")
 progress bar More...
 
void Progress (FILE *fp, bool bInit=false, const char *head="")
 progress bar for file More...
 
Logoperator<< (ostream &(*op)(ostream &))
 output. More...
 
Logoperator<< (int x)
 
Logoperator<< (short x)
 
Logoperator<< (long x)
 
Logoperator<< (long long x)
 
Logoperator<< (unsigned int x)
 
Logoperator<< (unsigned short x)
 
Logoperator<< (unsigned long x)
 
Logoperator<< (float x)
 
Logoperator<< (double x)
 
Logoperator<< (char x)
 
Logoperator<< (const char *x)
 
Logoperator<< (const void *x)
 
Logoperator<< (bool x)
 
Logoperator<< (string &x)
 

Protected Attributes

ofstream m_fileLog
 log file stream More...
 
bool m_bOutputLog
 if output to the log file More...
 
bool m_bOutputCmd
 if output to the cmd window More...
 
short m_nLevel
 output level More...
 
ProgressBar m_bar
 the build-in progerss bar. More...
 

Detailed Description

this class can output to the cmd window and log files simultaneously. In wb-log.cpp, there are a Log variable "lout", which can be directly used just like "cout". For example:

Author
WangBin
Date
2013-8-29
lout<<"Hello Wrold!"<<endl;
"lout" has the following advantages:
  1. It can output to the cmd and the log file. Besides they can be controled.
  2. It can output the begin and end date of the program.
  3. If the output varialbes are bools, then it will output true/false
  4. If the output variables are char*, then it will detect if the pointer is NULL.
  5. There are some macros, such as lout_variable, lout_error, lout_waring and so on;
  6. Include a progress bar function which can output a progress bar on the console window

Definition at line 110 of file wb-log.h.

Constructor & Destructor Documentation

§ Log()

wb::Log::Log ( )

constructor

Definition at line 24 of file wb-log.cpp.

§ ~Log()

wb::Log::~Log ( )

destructor

Definition at line 56 of file wb-log.cpp.

Member Function Documentation

§ bOutputCmd()

bool & wb::Log::bOutputCmd ( )

if output to the cmd window

�Ƿ������cmd����

Definition at line 96 of file wb-log.cpp.

§ bOutputLog()

bool & wb::Log::bOutputLog ( )

if output to the log file

�Ƿ������log�ļ�

Definition at line 98 of file wb-log.cpp.

§ LevelDown()

void wb::Log::LevelDown ( )

level down

��������������һ��

Definition at line 142 of file wb-log.cpp.

§ LevelUp()

void wb::Log::LevelUp ( )

level up

��������������

Definition at line 144 of file wb-log.cpp.

§ operator<<() [1/15]

Log & wb::Log::operator<< ( ostream &(*)(ostream &)  op)

output.

Definition at line 100 of file wb-log.cpp.

§ operator<<() [2/15]

Log & wb::Log::operator<< ( int  x)

Definition at line 101 of file wb-log.cpp.

§ operator<<() [3/15]

Log & wb::Log::operator<< ( short  x)

Definition at line 102 of file wb-log.cpp.

§ operator<<() [4/15]

Log & wb::Log::operator<< ( long  x)

Definition at line 103 of file wb-log.cpp.

§ operator<<() [5/15]

Log & wb::Log::operator<< ( long long  x)

Definition at line 104 of file wb-log.cpp.

§ operator<<() [6/15]

Log & wb::Log::operator<< ( unsigned int  x)

Definition at line 105 of file wb-log.cpp.

§ operator<<() [7/15]

Log & wb::Log::operator<< ( unsigned short  x)

Definition at line 106 of file wb-log.cpp.

§ operator<<() [8/15]

Log & wb::Log::operator<< ( unsigned long  x)

Definition at line 107 of file wb-log.cpp.

§ operator<<() [9/15]

Log & wb::Log::operator<< ( float  x)

Definition at line 108 of file wb-log.cpp.

§ operator<<() [10/15]

Log & wb::Log::operator<< ( double  x)

Definition at line 109 of file wb-log.cpp.

§ operator<<() [11/15]

Log & wb::Log::operator<< ( char  x)

Definition at line 110 of file wb-log.cpp.

§ operator<<() [12/15]

Log & wb::Log::operator<< ( const char *  x)

Definition at line 111 of file wb-log.cpp.

§ operator<<() [13/15]

Log & wb::Log::operator<< ( const void *  x)

Definition at line 120 of file wb-log.cpp.

§ operator<<() [14/15]

Log & wb::Log::operator<< ( bool  x)

Definition at line 129 of file wb-log.cpp.

§ operator<<() [15/15]

Log & wb::Log::operator<< ( string &  x)

Definition at line 138 of file wb-log.cpp.

§ Progress() [1/2]

void wb::Log::Progress ( long long  n = -1,
bool  bInit = false,
long long  total = 100,
const char *  head = "" 
)

progress bar

Definition at line 146 of file wb-log.cpp.

§ Progress() [2/2]

void wb::Log::Progress ( FILE *  fp,
bool  bInit = false,
const char *  head = "" 
)

progress bar for file

Definition at line 155 of file wb-log.cpp.

§ ReFile()

void wb::Log::ReFile ( const char *  path,
bool  bNew = true 
)

relocate the log file. The defualt log file is "program name".log

���¶�λlog������ļ���bNew�Ƿ����´����ļ���������Ѵ����ļ����ݣ�

Parameters
[in]paththe file path
[in]bNewsetting true will clean the log file.

Definition at line 68 of file wb-log.cpp.

Member Data Documentation

§ m_bar

ProgressBar wb::Log::m_bar
protected

the build-in progerss bar.

Definition at line 119 of file wb-log.h.

§ m_bOutputCmd

bool wb::Log::m_bOutputCmd
protected

if output to the cmd window

Definition at line 115 of file wb-log.h.

§ m_bOutputLog

bool wb::Log::m_bOutputLog
protected

if output to the log file

Definition at line 114 of file wb-log.h.

§ m_fileLog

ofstream wb::Log::m_fileLog
protected

log file stream

Definition at line 113 of file wb-log.h.

§ m_nLevel

short wb::Log::m_nLevel
protected

output level

Definition at line 117 of file wb-log.h.


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