Class TsurugiSessionTxFileLogger
- java.lang.Object
-
- com.tsurugidb.iceaxe.session.event.logging.TsurugiSessionTxLogger
-
- com.tsurugidb.iceaxe.session.event.logging.file.TsurugiSessionTxFileLogger
-
- All Implemented Interfaces:
TsurugiSessionEventListener
public class TsurugiSessionTxFileLogger extends TsurugiSessionTxLogger
Tsurugi transaction logger to file.
-
-
Field Summary
Fields Modifier and Type Field Description protected TsurugiSessionTxFileLogConfig
config
transaction file log config
-
Constructor Summary
Constructors Constructor Description TsurugiSessionTxFileLogger(TsurugiSessionTxFileLogConfig config)
Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.nio.file.Path
createOutputDir(java.nio.file.Path file)
create output directory.protected java.io.PrintWriter
createPrintWriter(TsurugiSessionTxFileLogConfig config, java.nio.file.Path file)
create print writer.protected TsurugiSessionTxFileLogWriter
createWriter(TgSessionTxLog txLog)
create writer.protected long
elapsed(java.time.ZonedDateTime start, java.time.ZonedDateTime end)
get elapsed.protected java.lang.String
getLogDirNameTm(TgSessionTxLog txLog)
get log directory name for transaction manager.protected java.lang.String
getLogDirNameTx(TgSessionTxLog txLog)
get log directory name for transaction.protected java.lang.String
getLogFileName(TgSessionTxLog txLog)
get log file name.protected TsurugiSessionTxFileLogWriter
getWriter(TgSessionTxLog txLog)
get writer.protected void
logCreateSqlStatement(TsurugiSql ps)
called when create SQL definition.protected void
logLowTransactionGetEnd(TgSessionTxLog txLog, java.lang.String transactionId, java.lang.Throwable occurred)
called when get transactionId.protected void
logLowTransactionGetStart(TgSessionTxLog txLog)
called when get transactionId.void
logSessionClose(TsurugiSession session, java.lang.Throwable occurred)
called when close session.protected void
logSqlClose(TgSessionTxLog txLog, TgSessionSqlLog sqlLog, java.lang.Throwable occurred)
called when SQL result close.protected void
logSqlEnd(TgSessionTxLog txLog, TgSessionSqlLog sqlLog, java.lang.Throwable occurred)
called when SQL execute end.protected void
logSqlExplain(int sqlId, int ssId, TsurugiSessionTxFileLogWriter writer, IoSupplier<TgStatementMetadata> explainSupplier)
output SQL explain.protected <R> void
logSqlRead(TgSessionTxLog txLog, TgSessionSqlLog sqlLog, TsurugiQueryResult<R> result, R record)
called when SQL read.protected <R> void
logSqlReadException(TgSessionTxLog txLog, TgSessionSqlLog sqlLog, TsurugiQueryResult<R> result, java.lang.Throwable occurred)
called when occurs exception SQL read.protected void
logSqlStart(TgSessionTxLog txLog, TgSessionSqlLog sqlLog)
called when SQL execute start.protected void
logSqlStartException(TgSessionTxLog txLog, TgSessionSqlLog sqlLog, java.lang.Throwable occurred)
called when occurs exception SQL execute start.protected void
logTmExecuteException(TgSessionTxLog txLog, java.lang.Throwable occurred)
called when occurs transactionManager execute error.protected void
logTmExecuteRetry(TgSessionTxLog txLog, java.lang.Exception cause, TgTmTxOption nextTmOption)
called when transactionManager execute retry.protected void
logTransactionClose(TgSessionTxLog txLog, java.lang.Throwable occurred)
called when transaction close.protected void
logTransactionCommitEnd(TgSessionTxLog txLog, TgCommitType commitType, java.lang.Throwable occurred)
called when commit end.protected void
logTransactionCommitStart(TgSessionTxLog txLog, TgCommitType commitType)
called when commit start.protected void
logTransactionRollbackEnd(TgSessionTxLog txLog, java.lang.Throwable occurred)
called when rollback end.protected void
logTransactionRollbackStart(TgSessionTxLog txLog)
called when rollback start.protected void
logTransactionSqlEnd(TsurugiTransaction.TgTxMethod method, TgSessionTxLog txLog, TgSessionTxLog.TgSessionTxExecuteLog exLog, TsurugiSql ps, java.lang.Object parameter, TsurugiSqlResult result, java.lang.Throwable occurred)
called when execute SQL end.protected void
logTransactionSqlStart(TsurugiTransaction.TgTxMethod method, TgSessionTxLog txLog, TgSessionTxLog.TgSessionTxExecuteLog exLog, TsurugiSql ps, java.lang.Object parameter)
called when execute SQL start.protected void
logTransactionStart(TgSessionTxLog txLog)
called when transaction start.-
Methods inherited from class com.tsurugidb.iceaxe.session.event.logging.TsurugiSessionTxLogger
closeSession, createQuery, createQuery, createStatement, createStatement, createTmLog, createTransaction, createTransactionManager, createTxLog, doLogSqlClose, doLogSqlEnd, doLogSqlRead, doLogSqlReadException, doLogSqlStart, doLogSqlStarted, doLogSqlStartException, doLogTmExecuteEnd, doLogTmExecuteException, doLogTmExecuteRetry, doLogTmExecuteStart, doLogTransactionClose, doLogTransactionCommitEnd, doLogTransactionCommitStart, doLogTransactionRollbackEnd, doLogTransactionRollbackStart, doLogTransactionSqlEnd, doLogTransactionSqlStart, doLogTransactionStart, doLowTransactionGetEnd, doLowTransactionGetStart, getTmLog, getTxLog, logSessionShutdown, logSqlStarted, logTmExecuteEnd, logTmExecuteStart, shutdownSession
-
-
-
-
Field Detail
-
config
protected final TsurugiSessionTxFileLogConfig config
transaction file log config
-
-
Constructor Detail
-
TsurugiSessionTxFileLogger
public TsurugiSessionTxFileLogger(TsurugiSessionTxFileLogConfig config)
Creates a new instance.- Parameters:
config
- transaction file log config
-
-
Method Detail
-
logCreateSqlStatement
protected void logCreateSqlStatement(TsurugiSql ps)
Description copied from class:TsurugiSessionTxLogger
called when create SQL definition.- Overrides:
logCreateSqlStatement
in classTsurugiSessionTxLogger
- Parameters:
ps
- SQL definition
-
logTransactionStart
protected void logTransactionStart(TgSessionTxLog txLog)
Description copied from class:TsurugiSessionTxLogger
called when transaction start.- Overrides:
logTransactionStart
in classTsurugiSessionTxLogger
- Parameters:
txLog
- transaction log
-
createWriter
protected TsurugiSessionTxFileLogWriter createWriter(TgSessionTxLog txLog) throws java.io.UncheckedIOException
create writer.- Parameters:
txLog
- transaction log- Returns:
- writer
- Throws:
java.io.UncheckedIOException
- if an I/O error occurs opening or creating the file
-
getLogFileName
protected java.lang.String getLogFileName(TgSessionTxLog txLog)
get log file name.- Parameters:
txLog
- transaction log- Returns:
- file name
-
getLogDirNameTm
protected java.lang.String getLogDirNameTm(TgSessionTxLog txLog)
get log directory name for transaction manager.- Parameters:
txLog
- transaction log- Returns:
- directory name
-
getLogDirNameTx
protected java.lang.String getLogDirNameTx(TgSessionTxLog txLog)
get log directory name for transaction.- Parameters:
txLog
- transaction log- Returns:
- directory name
-
createOutputDir
protected java.nio.file.Path createOutputDir(java.nio.file.Path file) throws java.io.IOException
create output directory.- Parameters:
file
- file path- Returns:
- output directory path
- Throws:
java.io.IOException
- if an I/O error occurs- Since:
- 1.3.0
-
createPrintWriter
protected java.io.PrintWriter createPrintWriter(TsurugiSessionTxFileLogConfig config, java.nio.file.Path file) throws java.io.IOException
create print writer.- Parameters:
config
- transaction file log configfile
- file path- Returns:
- print writer
- Throws:
java.io.IOException
- if an I/O error occurs opening or creating the file- Since:
- 1.3.0
-
getWriter
protected TsurugiSessionTxFileLogWriter getWriter(TgSessionTxLog txLog)
get writer.- Parameters:
txLog
- transaction log- Returns:
- writer
-
logLowTransactionGetStart
protected void logLowTransactionGetStart(TgSessionTxLog txLog)
Description copied from class:TsurugiSessionTxLogger
called when get transactionId.- Overrides:
logLowTransactionGetStart
in classTsurugiSessionTxLogger
- Parameters:
txLog
- transaction log
-
logLowTransactionGetEnd
protected void logLowTransactionGetEnd(TgSessionTxLog txLog, java.lang.String transactionId, java.lang.Throwable occurred)
Description copied from class:TsurugiSessionTxLogger
called when get transactionId.- Overrides:
logLowTransactionGetEnd
in classTsurugiSessionTxLogger
- Parameters:
txLog
- transaction logtransactionId
- transactionIdoccurred
- exception
-
logTransactionSqlStart
protected void logTransactionSqlStart(TsurugiTransaction.TgTxMethod method, TgSessionTxLog txLog, TgSessionTxLog.TgSessionTxExecuteLog exLog, TsurugiSql ps, java.lang.Object parameter)
Description copied from class:TsurugiSessionTxLogger
called when execute SQL start.- Overrides:
logTransactionSqlStart
in classTsurugiSessionTxLogger
- Parameters:
method
- execute methodtxLog
- transaction logexLog
- transaction SQL execute logps
- SQL definitionparameter
- SQL parameter
-
logTransactionSqlEnd
protected void logTransactionSqlEnd(TsurugiTransaction.TgTxMethod method, TgSessionTxLog txLog, TgSessionTxLog.TgSessionTxExecuteLog exLog, TsurugiSql ps, java.lang.Object parameter, @Nullable TsurugiSqlResult result, @Nullable java.lang.Throwable occurred)
Description copied from class:TsurugiSessionTxLogger
called when execute SQL end.- Overrides:
logTransactionSqlEnd
in classTsurugiSessionTxLogger
- Parameters:
method
- execute methodtxLog
- transaction logexLog
- transaction SQL execute logps
- SQL definitionparameter
- SQL parameterresult
- SQL resultoccurred
- exception
-
logSqlStart
protected void logSqlStart(TgSessionTxLog txLog, TgSessionSqlLog sqlLog)
Description copied from class:TsurugiSessionTxLogger
called when SQL execute start.- Overrides:
logSqlStart
in classTsurugiSessionTxLogger
- Parameters:
txLog
- transaction logsqlLog
- SQL log
-
logSqlExplain
protected void logSqlExplain(int sqlId, int ssId, TsurugiSessionTxFileLogWriter writer, IoSupplier<TgStatementMetadata> explainSupplier)
output SQL explain.- Parameters:
sqlId
- iceaxe SQL executeIdssId
- iceaxe sqlIdwriter
- writerexplainSupplier
- supplier of explain
-
logSqlStartException
protected void logSqlStartException(TgSessionTxLog txLog, TgSessionSqlLog sqlLog, java.lang.Throwable occurred)
Description copied from class:TsurugiSessionTxLogger
called when occurs exception SQL execute start.- Overrides:
logSqlStartException
in classTsurugiSessionTxLogger
- Parameters:
txLog
- transaction logsqlLog
- SQL logoccurred
- exception
-
logSqlRead
protected <R> void logSqlRead(TgSessionTxLog txLog, TgSessionSqlLog sqlLog, TsurugiQueryResult<R> result, R record)
Description copied from class:TsurugiSessionTxLogger
called when SQL read.- Overrides:
logSqlRead
in classTsurugiSessionTxLogger
- Type Parameters:
R
- result type- Parameters:
txLog
- transaction logsqlLog
- SQL logresult
- SQL resultrecord
- record
-
logSqlReadException
protected <R> void logSqlReadException(TgSessionTxLog txLog, TgSessionSqlLog sqlLog, TsurugiQueryResult<R> result, java.lang.Throwable occurred)
Description copied from class:TsurugiSessionTxLogger
called when occurs exception SQL read.- Overrides:
logSqlReadException
in classTsurugiSessionTxLogger
- Type Parameters:
R
- record type- Parameters:
txLog
- transaction logsqlLog
- SQL logresult
- SQL resultoccurred
- exception
-
logSqlEnd
protected void logSqlEnd(TgSessionTxLog txLog, TgSessionSqlLog sqlLog, @Nullable java.lang.Throwable occurred)
Description copied from class:TsurugiSessionTxLogger
called when SQL execute end.- Overrides:
logSqlEnd
in classTsurugiSessionTxLogger
- Parameters:
txLog
- transaction logsqlLog
- SQL logoccurred
- exception
-
logSqlClose
protected void logSqlClose(TgSessionTxLog txLog, TgSessionSqlLog sqlLog, java.lang.Throwable occurred)
Description copied from class:TsurugiSessionTxLogger
called when SQL result close.- Overrides:
logSqlClose
in classTsurugiSessionTxLogger
- Parameters:
txLog
- transaction logsqlLog
- SQL logoccurred
- exception
-
logTransactionCommitStart
protected void logTransactionCommitStart(TgSessionTxLog txLog, TgCommitType commitType)
Description copied from class:TsurugiSessionTxLogger
called when commit start.- Overrides:
logTransactionCommitStart
in classTsurugiSessionTxLogger
- Parameters:
txLog
- transaction logcommitType
- commit type
-
logTransactionCommitEnd
protected void logTransactionCommitEnd(TgSessionTxLog txLog, TgCommitType commitType, java.lang.Throwable occurred)
Description copied from class:TsurugiSessionTxLogger
called when commit end.- Overrides:
logTransactionCommitEnd
in classTsurugiSessionTxLogger
- Parameters:
txLog
- transaction logcommitType
- commit typeoccurred
- exception
-
logTransactionRollbackStart
protected void logTransactionRollbackStart(TgSessionTxLog txLog)
Description copied from class:TsurugiSessionTxLogger
called when rollback start.- Overrides:
logTransactionRollbackStart
in classTsurugiSessionTxLogger
- Parameters:
txLog
- transaction log
-
logTransactionRollbackEnd
protected void logTransactionRollbackEnd(TgSessionTxLog txLog, java.lang.Throwable occurred)
Description copied from class:TsurugiSessionTxLogger
called when rollback end.- Overrides:
logTransactionRollbackEnd
in classTsurugiSessionTxLogger
- Parameters:
txLog
- transaction logoccurred
- exception
-
logTmExecuteException
protected void logTmExecuteException(TgSessionTxLog txLog, java.lang.Throwable occurred)
Description copied from class:TsurugiSessionTxLogger
called when occurs transactionManager execute error.- Overrides:
logTmExecuteException
in classTsurugiSessionTxLogger
- Parameters:
txLog
- transaction logoccurred
- exception
-
logTmExecuteRetry
protected void logTmExecuteRetry(TgSessionTxLog txLog, java.lang.Exception cause, TgTmTxOption nextTmOption)
Description copied from class:TsurugiSessionTxLogger
called when transactionManager execute retry.- Overrides:
logTmExecuteRetry
in classTsurugiSessionTxLogger
- Parameters:
txLog
- transaction logcause
- retry exceptionnextTmOption
- next transaction option
-
logTransactionClose
protected void logTransactionClose(TgSessionTxLog txLog, java.lang.Throwable occurred)
Description copied from class:TsurugiSessionTxLogger
called when transaction close.- Overrides:
logTransactionClose
in classTsurugiSessionTxLogger
- Parameters:
txLog
- transaction logoccurred
- exception
-
elapsed
protected long elapsed(java.time.ZonedDateTime start, java.time.ZonedDateTime end)
get elapsed.- Parameters:
start
- start timeend
- end time- Returns:
- elapsed[ms]
-
logSessionClose
public void logSessionClose(TsurugiSession session, java.lang.Throwable occurred)
Description copied from class:TsurugiSessionTxLogger
called when close session.- Overrides:
logSessionClose
in classTsurugiSessionTxLogger
- Parameters:
session
- sessionoccurred
- exception
-
-