StRoot
1
|
Public Member Functions | |
virtual void | setOption (const String &option, const String &value) |
void | append (const spi::LoggingEventPtr &event) |
virtual void | close () |
void | flushBuffer () |
virtual bool | requiresLayout () const |
void | setSql (const String &s) |
const String & | getSql () const |
void | setUser (const String &user) |
void | setURL (const String &url) |
void | setPassword (const String &password) |
void | setBufferSize (size_t newBufferSize) |
const String & | getUser () const |
const String & | getURL () const |
const String & | getPassword () const |
size_t | getBufferSize () const |
Protected Member Functions | |
String | getLogStatement (const spi::LoggingEventPtr &event) |
unsigned int | execute (const String &sql) |
virtual void | closeConnection () |
virtual MYSQL * | getConnection () |
Protected Attributes | |
String | databaseURL |
String | databaseUser |
String | databasePassword |
MYSQL * | connection |
String | sqlStatement |
size_t | bufferSize |
std::list< spi::LoggingEventPtr > | buffer |
unsigned long | fLastId |
bool | fIsConnectionOpen |
Definition at line 98 of file MySQLAppender.h.
void MySQLAppender::append | ( | const spi::LoggingEventPtr & | event | ) |
Adds the event to the buffer. When full the buffer is flushed.
Definition at line 84 of file MySQLAppender.cxx.
|
virtual |
Closes the appender, flushing the buffer first then closing the default connection if it is open.
Definition at line 181 of file MySQLAppender.cxx.
|
protectedvirtual |
Override this to return the connection to a pool, or to clean up the resource.
The default behavior holds a single connection open until the appender is closed (typically when garbage collected).
Definition at line 134 of file MySQLAppender.cxx.
|
protected |
Override this to provide an alertnate method of getting connections (such as caching). One method to fix this is to open connections at the start of flushBuffer() and close them at the end. I use a connection pool outside of MySQLAppender which is accessed in an override of this method.
Definition at line 108 of file MySQLAppender.cxx.
void MySQLAppender::flushBuffer | ( | ) |
loops through the buffer of LoggingEvents, gets a sql string from getLogStatement() and sends it to execute(). Errors are sent to the errorHandler.
If a statement fails the LoggingEvent stays in the buffer!
— Task description
Definition at line 212 of file MySQLAppender.cxx.
|
protectedvirtual |
Override this to link with your connection pooling system.
By default this creates a single connection which is held open until the object is garbage collected.
Definition at line 146 of file MySQLAppender.cxx.
|
protected |
By default getLogStatement sends the event to the required Layout object. The layout will format the given pattern into a workable SQL string.
Overriding this provides direct access to the LoggingEvent when constructing the logging statement.
Definition at line 94 of file MySQLAppender.cxx.
|
inline |
Returns pre-formated statement eg: insert into LogTable (msg) values ("%m")
Definition at line 243 of file MySQLAppender.h.
|
inlinevirtual |
MySQLAppender requires a layout.
Definition at line 232 of file MySQLAppender.h.
|
virtual |
Set options
Definition at line 53 of file MySQLAppender.cxx.
void MySQLAppender::setSql | ( | const String & | s | ) |
Set pre-formated statement eg: insert into LogTable (msg) values ("%m")
Definition at line 333 of file MySQLAppender.cxx.
|
protected |
ArrayList holding the buffer of Logging Events.
Definition at line 145 of file MySQLAppender.h.
|
protected |
size of LoggingEvent buffer before writting to the database. Default is 1.
Definition at line 140 of file MySQLAppender.h.
|
protected |
Connection used by default. The connection is opened the first time it is needed and then held open until the appender is closed (usually at garbage collection). This behavior is best modified by creating a sub-class and overriding the getConnection
and closeConnection
methods.
Definition at line 123 of file MySQLAppender.h.
|
protected |
User to use for default connection handling
Definition at line 114 of file MySQLAppender.h.
|
protected |
URL of the DB for default connection handling
Definition at line 104 of file MySQLAppender.h.
|
protected |
User to connect as for default connection handling
Definition at line 109 of file MySQLAppender.h.
|
protected |
Stores the string given to the pattern layout for conversion into a SQL statement, eg: insert into LogTable (Thread, File, Message) values ("%t", "%F", "%m")
Be careful of quotes in your messages!
Also see PatternLayout.
Definition at line 134 of file MySQLAppender.h.