MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FileLogHandler.hpp
1 /*
2  Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; version 2 of the License.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #ifndef FILELOGHANDLER_H
19 #define FILELOGHANDLER_H
20 
21 #include "LogHandler.hpp"
22 
23 class File_class;
24 
37 class FileLogHandler : public LogHandler
38 {
39 public:
40 
41  virtual const char* handler_type() {return "FILE"; };
42 
52  FileLogHandler(const char* aFileName = "logger.log",
53  int maxNoFiles = 6,
54  long maxFileSize = 1024000,
55  unsigned int maxLogEntries = 10000);
56 
60  virtual ~FileLogHandler();
61 
62  virtual bool open();
63  virtual bool close();
64 
65  virtual bool is_open();
66 
67  virtual bool setParam(const BaseString &param, const BaseString &value);
68  virtual bool checkParams();
69 
70  virtual bool getParams(BaseString &config);
71 
72  virtual off_t getCurrentSize();
73  virtual off_t getMaxSize() { return m_maxFileSize; };
74 
75 protected:
76  virtual void writeHeader(const char* pCategory, Logger::LoggerLevel level);
77  virtual void writeMessage(const char* pMsg);
78  virtual void writeFooter();
79 
80 private:
83  FileLogHandler operator = (const FileLogHandler&);
84  bool operator == (const FileLogHandler&);
85 
89  bool isTimeForNewFile();
90 
97  bool createNewFile();
98 
99  bool setFilename(const BaseString &filename);
100  bool setMaxSize(const BaseString &size);
101  bool setMaxFiles(const BaseString &files);
102 
103  int m_maxNoFiles;
104  off_t m_maxFileSize;
105  unsigned int m_maxLogEntries;
106  File_class* m_pLogFile;
107 };
108 
109 #endif