File: wvlogfile.h

package info (click to toggle)
wvstreams 4.0.2-4
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 6,420 kB
  • ctags: 6,518
  • sloc: cpp: 52,544; sh: 5,770; ansic: 810; makefile: 461; tcl: 114; perl: 18
file content (45 lines) | stat: -rw-r--r-- 1,165 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* -*- Mode: C++ -*-
 * Worldvisions Weaver Software:
 *   Copyright (C) 1997-2002 Net Integration Technologies, Inc.
 *
 * A "Log Receiver" that logs messages to a file 
 */

#ifndef __WVLOGFILE_H
#define __WVLOGFILE_H

#include "wvfile.h"
#include "wvlogrcv.h"

/// Basic WvLogRcv that logs to a file. Always logs to the same file.
/// No auto-rotation of log files.
class WvLogFileBase : public WvLogRcv, public WvFile
{
public:
    WvLogFileBase(WvStringParm _filename,
		  WvLog::LogLevel _max_level = WvLog::NUM_LOGLEVELS);
    
protected:
    WvLogFileBase(WvLog::LogLevel _max_level);
    virtual void _make_prefix(); 
    virtual void _mid_line(const char *str, size_t len);
};


/// A more advanced WvLogFileBase.  Logs to a file named <filename>.<date>.
/// Deletes old log files after 'keep_for' days.
class WvLogFile : public WvLogFileBase
{
public:
    WvLogFile(WvStringParm _filename,
	      WvLog::LogLevel _max_level = WvLog::NUM_LOGLEVELS,
	      int _keep_for = 7, bool _force_new_line = false);
    
private:
    virtual void _make_prefix(); 
    void start_log();
    int keep_for, last_day;
    WvString filename;
};

#endif // __WVLOGFILE_H