4
* Copyright 2000, LifeLine Networks BV (www.lifeline.nl). All rights reserved.
5
* Copyright 2000, Bastiaan Bakker. All rights reserved.
7
* See the COPYING file for the terms of usage and distribution.
10
#ifndef _LOG4SHIB_FILEAPPENDER_HH
11
#define _LOG4SHIB_FILEAPPENDER_HH
13
#include <log4shib/Portability.hh>
14
#include <log4shib/LayoutAppender.hh>
20
class LOG4SHIB_EXPORT FileAppender : public LayoutAppender {
24
Constructs a FileAppender.
25
@param name the name of the Appender.
26
@param fileName the name of the file to which the Appender has
28
@param append whether the Appender has to truncate the file or
29
just append to it if it already exists. Defaults to 'true'.
30
@param mode file mode to open the logfile with. Defaults to 00644.
32
FileAppender(const std::string& name, const std::string& fileName,
33
bool append = true, mode_t mode = 00644);
36
Constructs a FileAppender to an already open file descriptor.
37
@param name the name of the Appender.
38
@param fd the file descriptor to which the Appender has to log.
40
FileAppender(const std::string& name, int fd);
41
virtual ~FileAppender();
45
This can be useful for logfiles that are rotated externally,
46
e.g. by logrotate. This method is a NOOP for FileAppenders that
47
have been constructed with a file descriptor.
48
@returns true if the reopen succeeded.
50
virtual bool reopen();
58
Sets the append vs truncate flag.
59
NB. currently the FileAppender opens the logfile in the
60
constructor. Therefore this method is too late to influence the
61
first file opening. We'll need something similar to log4j's
63
@param append false to truncate, true to append
65
virtual void setAppend(bool append);
68
Gets the value of the 'append' option.
70
virtual bool getAppend() const;
73
Sets the file open mode.
75
virtual void setMode(mode_t mode);
78
Gets the file open mode.
80
virtual mode_t getMode() const;
83
virtual void _append(const LoggingEvent& event);
85
const std::string _fileName;
92
#endif // _LOG4SHIB_FILEAPPENDER_HH