WvStreams
wvlogfile.h
1 /* -*- Mode: C++ -*-
2  * Worldvisions Weaver Software:
3  * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
4  *
5  * A "Log Receiver" that logs messages to a file
6  */
7 
8 #ifndef __WVLOGFILE_H
9 #define __WVLOGFILE_H
10 
11 #include "wvfile.h"
12 #include "wvlogrcv.h"
13 
16 class WvLogFileBase : public WvLogRcv, public WvFile
17 {
18 public:
19  WvLogFileBase(WvStringParm _filename,
20  WvLog::LogLevel _max_level = WvLog::NUM_LOGLEVELS);
21 
22  // run fsync() every so many log messages. 0 never fsyncs.
23  int fsync_every;
24 
25 protected:
26  WvLogFileBase(WvLog::LogLevel _max_level);
27  virtual void _make_prefix(time_t now_sec);
28  virtual void _mid_line(const char *str, size_t len);
29  virtual void _end_line();
30 
31  int fsync_count;
32 };
33 
34 
37 class WvLogFile : public WvLogFileBase
38 {
39 public:
40  WvLogFile(WvStringParm _filename,
41  WvLog::LogLevel _max_level = WvLog::NUM_LOGLEVELS,
42  int _keep_for = 7, bool _force_new_line = false,
43  bool _allow_append = true);
44 
45  WvString start_log();
46 
47 private:
48  virtual void _make_prefix(time_t now_sec);
49  int keep_for, last_day;
50  WvString filename;
51  bool allow_append;
52 
53 public:
54  const char *wstype() const { return "WvLogFileBase"; }
55 };
56 
57 #endif // __WVLOGFILE_H
WvFile
WvFile implements a stream connected to a file or Unix device.
Definition: wvfile.h:28
WvString
WvString is an implementation of a simple and efficient printable-string class.
Definition: wvstring.h:329
WvLogFile
A more advanced WvLogFileBase.
Definition: wvlogfile.h:37
WvLogFileBase::_make_prefix
virtual void _make_prefix(time_t now_sec)
Set the Prefix and Prefix Length (size_t prelen)
Definition: wvlogfile.cc:79
WvLogFileBase
Basic WvLogRcv that logs to a file.
Definition: wvlogfile.h:16
WvLogRcv
WvLogRcv adds some intelligence to WvLogRcvBase, to keep track of line-prefix-printing and other form...
Definition: wvlogrcv.h:28
WvLogFileBase::_mid_line
virtual void _mid_line(const char *str, size_t len)
add text to the current log line.
Definition: wvlogfile.cc:52
WvLogFileBase::_end_line
virtual void _end_line()
End this (Guaranteed NonEmpty) log line.
Definition: wvlogfile.cc:58