Holger's
Java API

com.antelmann.sql
Class MySQLLog

java.lang.Object
  extended by com.mysql.jdbc.log.StandardLogger
      extended by com.antelmann.sql.MySQLLog
All Implemented Interfaces:
LoggerProvider, com.mysql.jdbc.Extension, com.mysql.jdbc.log.Log, com.mysql.jdbc.profiler.ProfilerEventHandler

@ThirdParty(value="com.mysql.jdbc")
public class MySQLLog
extends com.mysql.jdbc.log.StandardLogger
implements com.mysql.jdbc.profiler.ProfilerEventHandler, LoggerProvider

a custom way to trace a MySQL flexibly over this' frameworks logging mechanism.

Since:
16.08.2015, 01:56:09
Author:
holger
See Also:
consumeEvent(ProfilerEvent), MySQLHelper.configureLogger(Connector, Class), Connection.getLog(), MySQLHelper.configureProfiler(Connector, Class), MySQLHelper.getProfileEventHandler(java.sql.Connection)

Field Summary
static Level LEVEL_EXECUTE
           
static Level LEVEL_FETCH
           
static Level LEVEL_OBJECT_CREATION
           
static Level LEVEL_PREPARE
           
static Level LEVEL_QUERY
           
static Level LEVEL_SLOW_QUERY
           
static Level LEVEL_WARN
           
static PatternExtractor<LogEntry,com.mysql.jdbc.profiler.ProfilerEvent> PROFILER_EXTRACTOR
           
 
Constructor Summary
MySQLLog()
          constructor for the use as ProfilerEventHandler
MySQLLog(String name)
          constructor for the use as Log
 
Method Summary
 void consumeEvent(com.mysql.jdbc.profiler.ProfilerEvent evt)
           
 void destroy()
           
protected  Level determineLevel(com.mysql.jdbc.profiler.ProfilerEvent ev)
           
protected  Object[] determineParams(com.mysql.jdbc.profiler.ProfilerEvent evt)
           
 DataMap<String> getDataMap()
          by default, this DataMap is not filled by the logged events.
 Logger getLogger()
          acess to the (non-null) Logger suitable for logging entries in the context of this instance
 void init(com.mysql.jdbc.Connection conn, Properties props)
           
 boolean isEnableDataMap()
           
protected  void logInternal(int level, Object msg, Throwable exception)
           
protected  void logInternalStandard(int level, Object msg, Throwable exception)
          allows access to the super implementation of logInternal(int, Object, Throwable) in subclasses
static void logStackTraceOnQuery(Connection con, File logFile, Filter<com.mysql.jdbc.profiler.ProfilerEvent> filter)
           
 void setDataLimit(int limit)
           
 void setEnableDataMap(boolean enableDataMap)
           
 
Methods inherited from class com.mysql.jdbc.log.StandardLogger
dropBuffer, getBuffer, isDebugEnabled, isErrorEnabled, isFatalEnabled, isInfoEnabled, isTraceEnabled, isWarnEnabled, logDebug, logDebug, logError, logError, logFatal, logFatal, logInfo, logInfo, logTrace, logTrace, logWarn, logWarn, startLoggingToBuffer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROFILER_EXTRACTOR

public static final PatternExtractor<LogEntry,com.mysql.jdbc.profiler.ProfilerEvent> PROFILER_EXTRACTOR

LEVEL_WARN

public static final Level LEVEL_WARN

LEVEL_OBJECT_CREATION

public static final Level LEVEL_OBJECT_CREATION

LEVEL_SLOW_QUERY

public static final Level LEVEL_SLOW_QUERY

LEVEL_EXECUTE

public static final Level LEVEL_EXECUTE

LEVEL_QUERY

public static final Level LEVEL_QUERY

LEVEL_FETCH

public static final Level LEVEL_FETCH

LEVEL_PREPARE

public static final Level LEVEL_PREPARE
Constructor Detail

MySQLLog

public MySQLLog()
constructor for the use as ProfilerEventHandler


MySQLLog

public MySQLLog(String name)
constructor for the use as Log

Method Detail

getLogger

public Logger getLogger()
Description copied from interface: LoggerProvider
acess to the (non-null) Logger suitable for logging entries in the context of this instance

Specified by:
getLogger in interface LoggerProvider

isEnableDataMap

public boolean isEnableDataMap()

setEnableDataMap

public void setEnableDataMap(boolean enableDataMap)

setDataLimit

public void setDataLimit(int limit)
See Also:
DataPoint.SUM_COMPARATOR, UniversalComparator.reverse(java.util.Comparator), DataMap.limitSize(int, java.util.Comparator)

getDataMap

public DataMap<String> getDataMap()
by default, this DataMap is not filled by the logged events.

See Also:
setEnableDataMap(boolean)

logInternal

protected void logInternal(int level,
                           Object msg,
                           Throwable exception)
Overrides:
logInternal in class com.mysql.jdbc.log.StandardLogger

logInternalStandard

protected void logInternalStandard(int level,
                                   Object msg,
                                   Throwable exception)
allows access to the super implementation of logInternal(int, Object, Throwable) in subclasses


init

public void init(com.mysql.jdbc.Connection conn,
                 Properties props)
          throws SQLException
Specified by:
init in interface com.mysql.jdbc.Extension
Throws:
SQLException

destroy

public void destroy()
Specified by:
destroy in interface com.mysql.jdbc.Extension

consumeEvent

public void consumeEvent(com.mysql.jdbc.profiler.ProfilerEvent evt)
Specified by:
consumeEvent in interface com.mysql.jdbc.profiler.ProfilerEventHandler

determineParams

protected Object[] determineParams(com.mysql.jdbc.profiler.ProfilerEvent evt)

determineLevel

protected Level determineLevel(com.mysql.jdbc.profiler.ProfilerEvent ev)

logStackTraceOnQuery

public static void logStackTraceOnQuery(Connection con,
                                        File logFile,
                                        Filter<com.mysql.jdbc.profiler.ProfilerEvent> filter)
                                 throws SQLException,
                                        IOException
Throws:
SQLException
IOException


(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads