SNAP Library 4.0, User 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>

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 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.

276  : LogFPath(_LogFPath), PrefixFNm(_PrefixFNm),
277  FlushP(_FlushP) {
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

Member Function Documentation

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

Definition at line 98 of file xfl.h.

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
void TFPathNotify::OnStatus ( const TStr MsgStr)

Reimplemented from TNotify.

Definition at line 283 of file xfl.cpp.

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
TFPathNotify::UndefDefaultCopyAssign ( TFPathNotify  )
void TFPathNotify::UpdateSOut ( const TTm NowTm)

Definition at line 268 of file xfl.cpp.

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

Member Data Documentation

TBool TFPathNotify::FlushP

Definition at line 90 of file xfl.h.

TTm TFPathNotify::LastTm

Definition at line 88 of file xfl.h.

TStr TFPathNotify::LogFPath

Definition at line 86 of file xfl.h.

PSOut TFPathNotify::LogSOut

Definition at line 89 of file xfl.h.

TStr TFPathNotify::PrefixFNm

Definition at line 87 of file xfl.h.

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