SNAP Library 4.0, Developer Reference  2017-07-27 13:18:06
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>

Inheritance diagram for TFPathNotify:
Collaboration diagram for TFPathNotify:

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 84 of file xfl.h.

Constructor & Destructor Documentation

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

Definition at line 275 of file xfl.cpp.

References TTm::GetCurUniTm(), LastTm, and UpdateSOut().

Referenced by New().

276  : LogFPath(_LogFPath), PrefixFNm(_PrefixFNm),
277  FlushP(_FlushP) {
278 
281 }
TStr PrefixFNm
Definition: xfl.h:87
static TTm GetCurUniTm()
Definition: tm.cpp:1029
TStr LogFPath
Definition: xfl.h:86
TTm LastTm
Definition: xfl.h:88
void UpdateSOut(const TTm &NowTm)
Definition: xfl.cpp:268
TBool FlushP
Definition: xfl.h:90

Here is the call graph for this function:

Here is the caller graph for this function:

Member Function Documentation

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

Definition at line 98 of file xfl.h.

References TFPathNotify().

98  {
99  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:275
TBool FlushP
Definition: xfl.h:90

Here is the call graph for this function:

void TFPathNotify::OnStatus ( const TStr MsgStr)
virtual

Reimplemented from TNotify.

Definition at line 283 of file xfl.cpp.

References TSOut::Flush(), FlushP, TTm::GetCurUniTm(), TTm::GetHour(), LastTm, LogSOut, TSOut::PutStrLn(), and UpdateSOut().

283  {
284  // check if new hour so we switch to new log file
285  TTm NowTm = TTm::GetCurUniTm();
286  if (NowTm.GetHour() != LastTm.GetHour()) {
287  LastTm = NowTm; UpdateSOut(LastTm);
288  }
289  // write log line
290  LogSOut->PutStrLn(MsgStr);
291  // we flush for each line when in debug mode
292  if (FlushP) { LogSOut->Flush(); }
293 }
static TTm GetCurUniTm()
Definition: tm.cpp:1029
int GetHour() const
Definition: tm.h:281
Definition: tm.h:213
virtual void Flush()=0
TTm LastTm
Definition: xfl.h:88
void UpdateSOut(const TTm &NowTm)
Definition: xfl.cpp:268
int PutStrLn(const TStr &Str, const bool &ForceInLn=false)
Definition: fl.h:161
TBool FlushP
Definition: xfl.h:90
PSOut LogSOut
Definition: xfl.h:89

Here is the call graph for this function:

TFPathNotify::UndefDefaultCopyAssign ( TFPathNotify  )
private
void TFPathNotify::UpdateSOut ( const TTm NowTm)
private

Definition at line 268 of file xfl.cpp.

References TPt< TRec >::Clr(), TStr::CStr(), TPt< TRec >::Empty(), TSOut::Flush(), TStr::Fmt(), TTm::GetDay(), TTm::GetHour(), TTm::GetMonth(), TTm::GetYear(), LogFPath, LogSOut, TFOut::New(), and PrefixFNm.

Referenced by OnStatus(), and TFPathNotify().

268  {
269  if (!LogSOut.Empty()) { LogSOut->Flush(); LogSOut.Clr(); }
270  TStr FNm = TStr::Fmt("%s-Y%04d-M%02d-D%02d-H%02d.log", PrefixFNm.CStr(),
271  Tm.GetYear(), Tm.GetMonth(), Tm.GetDay(), Tm.GetHour());
272  LogSOut = TFOut::New(LogFPath + FNm, true);
273 }
static PSOut New(const TStr &FNm, const bool &Append=false)
Definition: fl.cpp:442
TStr PrefixFNm
Definition: xfl.h:87
bool Empty() const
Definition: bd.h:501
void Clr()
Definition: bd.h:502
TStr LogFPath
Definition: xfl.h:86
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:89

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

TBool TFPathNotify::FlushP
private

Definition at line 90 of file xfl.h.

Referenced by OnStatus().

TTm TFPathNotify::LastTm
private

Definition at line 88 of file xfl.h.

Referenced by OnStatus(), and TFPathNotify().

TStr TFPathNotify::LogFPath
private

Definition at line 86 of file xfl.h.

Referenced by UpdateSOut().

PSOut TFPathNotify::LogSOut
private

Definition at line 89 of file xfl.h.

Referenced by OnStatus(), and UpdateSOut().

TStr TFPathNotify::PrefixFNm
private

Definition at line 87 of file xfl.h.

Referenced by UpdateSOut().


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