WvStreams
include/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
16class WvLogFileBase : public WvLogRcv, public WvFile
17{
18public:
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
25protected:
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
37class WvLogFile : public WvLogFileBase
38{
39public:
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
47private:
48 virtual void _make_prefix(time_t now_sec);
49 int keep_for, last_day;
50 WvString filename;
51 bool allow_append;
52
53public:
54 const char *wstype() const { return "WvLogFileBase"; }
55};
56
57#endif // __WVLOGFILE_H
A WvFastString acts exactly like a WvString, but can take (const char *) strings without needing to a...
WvFile implements a stream connected to a file or Unix device.
virtual void _end_line()
End this (Guaranteed NonEmpty) log line.
virtual void _make_prefix(time_t now_sec)
Set the Prefix and Prefix Length (size_t prelen)
virtual void _mid_line(const char *str, size_t len)
add text to the current log line.
WvLogRcv adds some intelligence to WvLogRcvBase, to keep track of line-prefix-printing and other form...
WvString is an implementation of a simple and efficient printable-string class.