SNAP Library 2.3, User Reference  2014-06-16 11:58:46
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TFPathNotify Class Reference

#include <xfl.h>

Inherits TNotify.

Public Member Functions

 TFPathNotify (const TStr &_LogFPath, const TStr &_PrefixFNm, const bool &_FlushP)
 
void OnStatus (const TStr &MsgStr)
 
- Public Member Functions inherited from TNotify
 TNotify ()
 
virtual ~TNotify ()
 
virtual void OnNotify (const TNotifyType &, const TStr &)
 
virtual void OnLn (const TStr &)
 
virtual void OnTxt (const TStr &)
 
void OnNotifyFmt (const TNotifyType &Type, const char *FmtStr,...)
 
void OnStatusFmt (const char *FmtStr,...)
 
void OnLnFmt (const char *FmtStr,...)
 
void OnTxtFmt (const char *FmtStr,...)
 

Static Public Member Functions

static PNotify New (const TStr &LogFPath, const TStr &PrefixFNm, const bool &FlushP)
 
- Static Public Member Functions inherited from TNotify
static TStr GetTypeStr (const TNotifyType &Type, const bool &Brief=true)
 
static void OnNotify (const PNotify &Notify, const TNotifyType &Type, const TStr &MsgStr)
 
static void OnStatus (const PNotify &Notify, const TStr &MsgStr)
 
static void OnLn (const PNotify &Notify, const TStr &MsgStr)
 
static void OnTxt (const PNotify &Notify, const TStr &MsgStr)
 
static void DfOnNotify (const TNotifyType &Type, const TStr &MsgStr)
 

Private Member Functions

void UpdateSOut (const TTm &NowTm)
 
 UndefDefaultCopyAssign (TFPathNotify)
 

Private Attributes

TStr LogFPath
 
TStr PrefixFNm
 
TTm LastTm
 
PSOut LogSOut
 
TBool FlushP
 

Additional Inherited Members

- Static Public Attributes inherited from TNotify
static const PNotify NullNotify =TNullNotify::New()
 
static const PNotify StdNotify =TStdNotify::New()
 
static const PNotify StdErrNotify =TStdErrNotify::New()
 

Detailed Description

Definition at line 83 of file xfl.h.

Constructor & Destructor Documentation

TFPathNotify::TFPathNotify ( const TStr _LogFPath,
const TStr _PrefixFNm,
const bool &  _FlushP 
)

Definition at line 266 of file xfl.cpp.

267  : LogFPath(_LogFPath), PrefixFNm(_PrefixFNm),
268  FlushP(_FlushP) {
269 
272 }
TStr PrefixFNm
Definition: xfl.h:86
static TTm GetCurUniTm()
Definition: tm.cpp:1024
TStr LogFPath
Definition: xfl.h:85
TTm LastTm
Definition: xfl.h:87
void UpdateSOut(const TTm &NowTm)
Definition: xfl.cpp:259
TBool FlushP
Definition: xfl.h:89

Member Function Documentation

static PNotify TFPathNotify::New ( const TStr LogFPath,
const TStr PrefixFNm,
const bool &  FlushP 
)
inlinestatic

Definition at line 97 of file xfl.h.

97  {
98  return PNotify(new TFPathNotify(LogFPath, PrefixFNm, FlushP));}
TPt< TNotify > PNotify
Definition: ut.h:30
TFPathNotify(const TStr &_LogFPath, const TStr &_PrefixFNm, const bool &_FlushP)
Definition: xfl.cpp:266
TBool FlushP
Definition: xfl.h:89
void TFPathNotify::OnStatus ( const TStr MsgStr)
virtual

Reimplemented from TNotify.

Definition at line 274 of file xfl.cpp.

274  {
275  // check if new hour so we switch to new log file
276  TTm NowTm = TTm::GetCurUniTm();
277  if (NowTm.GetHour() != LastTm.GetHour()) {
278  LastTm = NowTm; UpdateSOut(LastTm);
279  }
280  // write log line
281  LogSOut->PutStrLn(MsgStr);
282  // we flush for each line when in debug mode
283  if (FlushP) { LogSOut->Flush(); }
284 }
static TTm GetCurUniTm()
Definition: tm.cpp:1024
int GetHour() const
Definition: tm.h:280
Definition: tm.h:212
virtual void Flush()=0
TTm LastTm
Definition: xfl.h:87
void UpdateSOut(const TTm &NowTm)
Definition: xfl.cpp:259
int PutStrLn(const TStr &Str, const bool &ForceInLn=false)
Definition: fl.h:161
TBool FlushP
Definition: xfl.h:89
PSOut LogSOut
Definition: xfl.h:88
TFPathNotify::UndefDefaultCopyAssign ( TFPathNotify  )
private
void TFPathNotify::UpdateSOut ( const TTm NowTm)
private

Definition at line 259 of file xfl.cpp.

259  {
260  if (!LogSOut.Empty()) { LogSOut->Flush(); LogSOut.Clr(); }
261  TStr FNm = TStr::Fmt("%s-Y%04d-M%02d-D%02d-H%02d.log", PrefixFNm.CStr(),
262  Tm.GetYear(), Tm.GetMonth(), Tm.GetDay(), Tm.GetHour());
263  LogSOut = TFOut::New(LogFPath + FNm, true);
264 }
static PSOut New(const TStr &FNm, const bool &Append=false)
Definition: fl.cpp:442
TStr PrefixFNm
Definition: xfl.h:86
bool Empty() const
Definition: bd.h:501
void Clr()
Definition: bd.h:502
TStr LogFPath
Definition: xfl.h:85
virtual void Flush()=0
Definition: dt.h:412
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
char * CStr()
Definition: dt.h:476
PSOut LogSOut
Definition: xfl.h:88

Member Data Documentation

TBool TFPathNotify::FlushP
private

Definition at line 89 of file xfl.h.

TTm TFPathNotify::LastTm
private

Definition at line 87 of file xfl.h.

TStr TFPathNotify::LogFPath
private

Definition at line 85 of file xfl.h.

PSOut TFPathNotify::LogSOut
private

Definition at line 88 of file xfl.h.

TStr TFPathNotify::PrefixFNm
private

Definition at line 86 of file xfl.h.


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