19 #include <ndb_global.h>
20 #include <FileLogHandler.hpp>
21 #include <util/File.hpp>
29 unsigned int maxLogEntries) :
31 m_maxNoFiles(maxNoFiles),
32 m_maxFileSize(maxFileSize),
33 m_maxLogEntries(maxLogEntries)
48 if (m_pLogFile->
open())
50 if (isTimeForNewFile())
78 if (!m_pLogFile->
close())
90 char str[LogHandler::MAX_HEADER_LENGTH];
103 static int callCount = 0;
111 if (callCount % m_maxLogEntries != 0)
113 if (isTimeForNewFile())
115 if (!createNewFile())
134 FileLogHandler::isTimeForNewFile()
136 return (m_pLogFile->
size() >= m_maxFileSize);
139 off_t FileLogHandler::getCurrentSize()
141 return m_pLogFile->
size();
145 FileLogHandler::createNewFile()
149 char newName[PATH_MAX];
150 time_t newMtime, preMtime = 0;
154 if (fileNo >= m_maxNoFiles)
158 "%s.%d", m_pLogFile->
getName(), fileNo);
162 "%s.%d", m_pLogFile->
getName(), fileNo++);
164 if (newMtime < preMtime)
182 if (!m_pLogFile->
open())
193 if(param ==
"filename")
194 return setFilename(value);
195 if(param ==
"maxsize")
196 return setMaxSize(value);
197 if(param ==
"maxfiles")
198 return setMaxFiles(value);
205 config.
assfmt(
"FILE:filename=%s,maxsize=%lu,maxfiles=%u",
213 FileLogHandler::setFilename(
const BaseString &filename) {
224 long val = strtol(size.
c_str(), &end, 0);
225 if(size.
c_str() == end || val < 0)
241 FileLogHandler::setMaxFiles(
const BaseString &files) {
243 long val = strtol(files.
c_str(), &end, 0);
244 if(files.
c_str() == end || val < 1)
256 if(m_pLogFile == NULL)