QueryLoggerFile implements logging to a file for the QueryLog class. More...
#include <file.h>
Public Member Functions | |
bool | logEvent (const event_t *event) |
Format and write the event to the log file. More... | |
bool | openLogFile (const char *file) |
Open new log file, close old log file if successful. More... | |
bool | closeLogFile () |
Close the log file. More... | |
Private Attributes | |
std::ofstream | _fh |
File handle for open log file. | |
QueryLoggerFile implements logging to a file for the QueryLog class.
This class is not a plugin (class QueryLog is the plugin class), it is a utility class used by the QueryLog class to do the actual logging to the query log file. QueryLog deals with Drizzle; this class deals with formatting the event and writing it to the log file.
bool QueryLoggerFile::closeLogFile | ( | ) |
Close the log file.
If query_log_file_enabled is false, then the log file is closed. However, the log file is not closed if query_log_enabled is false.
true | Error, log file may not be closed |
false | Success, log file closed |
Definition at line 72 of file file.cc.
Referenced by drizzle_plugin::update_file_enabled().
bool QueryLoggerFile::logEvent | ( | const event_t * | event) |
Format and write the event to the log file.
This function is called by QueryLog::afterStatement(). The given event is a uniform struct (see event.h) and has passed filtering (thresholds, etc.), so it's ready to log.
[in] | event | Event to log |
true | Error, event not logged |
false | Success, event logged |
bool QueryLoggerFile::openLogFile | ( | const char * | file) |
Open new log file, close old log file if successful.
When global system variable query_log_file is changed, update_file() in module.cc is called which calls this function, passing it the new log file name. If opening the new log file succeeds, then the old log file is closed, else the old log if kept, and error is printed and query_log_file is not changed.
[in] | file | New log file name to open |
true | Error, new log file not opened, old log file still open |
false | Success, old log file closed, new log file opened |
Definition at line 61 of file file.cc.
Referenced by drizzle_plugin::init(), drizzle_plugin::update_file(), and drizzle_plugin::update_file_enabled().