38 #include "blocxx/BLOCXX_config.h" 46 #ifdef BLOCXX_HAVE_SYS_STAT_H 63 m_ok = file.getLock() == 0;
84 typedef blocxx::MultiProcessFileAppender app_t;
86 UInt64 kbytesToBytes(UInt64 max_size)
88 UInt64
const oneK = 1024;
89 UInt64
const biggest = UInt64(-1);
91 max_size == app_t::NO_MAX_LOG_SIZE ? biggest
92 : max_size > biggest / oneK ? biggest
105 UInt32 maxBackupIndex
108 , m_filename(filename)
109 , m_maxFileSize(kbytesToBytes(maxFileSize))
110 , m_maxBackupIndex(maxBackupIndex)
117 String msg =
"Cannot create log file " + filename;
122 String msg =
"Cannot create lock file for log file " + filename +
".lock";
161 String s = formattedMessage +
"\n";
virtual ~MultiProcessFileAppender()
MultiProcessFileAppender(const StringArray &components, const StringArray &categories, const String &filename, const String &pattern, UInt64 maxFileSize, UInt32 maxBackupIndex)
All processes that log to filename must use the same values for maxFileSize and maxBackupIndex.
UInt64 size() const
Current size of file.
BLOCXX_COMMON_API File openForAppendOrCreateFile(const String &path)
Opens the file for the given name to append data or create if it does not exist.
BLOCXX_COMMON_API File openOrCreateFile(const String &path)
Opens or creates the file for the given name.
This String class is an abstract data type that represents as NULL terminated string of characters...
virtual void doProcessLogMessage(const String &formattedMessage, const LogMessage &message) const
const char * c_str() const
BLOCXX_COMMON_API bool renameFile(const String &oldFileName, const String &newFileName)
Rename the given file to the new name.
BLOCXX_COMMON_API bool removeFile(const String &path)
Remove the given file.
int close()
Close the underlying file object.
The purpose of the File class is to provide an abstraction layer over the platform dependant function...
#define BLOCXX_THROW(exType, msg)
Throw an exception using FILE and LINE.
size_t write(const void *bfr, size_t numberOfBytes, Int64 offset=-1L)
Write to the underlying file.
unsigned m_maxBackupIndex
int flush()
Flush any buffered data to the file.