Saner handling if config.mk doesn't exist: use a default config.defaults.mk.
[wvstreams.git] / include / wvlogfile.h
blobfd4ee0e408a437f4d47553de85d76fbb40f033ca
1 /* -*- Mode: C++ -*-
2 * Worldvisions Weaver Software:
3 * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
5 * A "Log Receiver" that logs messages to a file
6 */
8 #ifndef __WVLOGFILE_H
9 #define __WVLOGFILE_H
11 #include "wvfile.h"
12 #include "wvlogrcv.h"
14 /// Basic WvLogRcv that logs to a file. Always logs to the same file.
15 /// No auto-rotation of log files.
16 class WvLogFileBase : public WvLogRcv, public WvFile
18 public:
19 WvLogFileBase(WvStringParm _filename,
20 WvLog::LogLevel _max_level = WvLog::NUM_LOGLEVELS);
22 // run fsync() every so many log messages. 0 never fsyncs.
23 int fsync_every;
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();
31 int fsync_count;
35 /// A more advanced WvLogFileBase. Logs to a file named <filename>.<date>.
36 /// Deletes old log files after 'keep_for' days.
37 class WvLogFile : public WvLogFileBase
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);
45 WvString start_log();
47 private:
48 virtual void _make_prefix(time_t now_sec);
49 int keep_for, last_day;
50 WvString filename;
51 bool allow_append;
53 public:
54 const char *wstype() const { return "WvLogFileBase"; }
57 #endif // __WVLOGFILE_H