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 TsurugiSessionTxFileLogConfigconfigtransaction 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.PathcreateOutputDir(java.nio.file.Path file)create output directory.protected java.io.PrintWritercreatePrintWriter(TsurugiSessionTxFileLogConfig config, java.nio.file.Path file)create print writer.protected TsurugiSessionTxFileLogWritercreateWriter(TgSessionTxLog txLog)create writer.protected longelapsed(java.time.ZonedDateTime start, java.time.ZonedDateTime end)get elapsed.protected java.lang.StringgetLogDirNameTm(TgSessionTxLog txLog)get log directory name for transaction manager.protected java.lang.StringgetLogDirNameTx(TgSessionTxLog txLog)get log directory name for transaction.protected java.lang.StringgetLogFileName(TgSessionTxLog txLog)get log file name.protected TsurugiSessionTxFileLogWritergetWriter(TgSessionTxLog txLog)get writer.protected voidlogCreateSqlStatement(TsurugiSql ps)called when create SQL definition.protected voidlogLowTransactionGetEnd(TgSessionTxLog txLog, java.lang.String transactionId, java.lang.Throwable occurred)called when get transactionId.protected voidlogLowTransactionGetStart(TgSessionTxLog txLog)called when get transactionId.voidlogSessionClose(TsurugiSession session, java.lang.Throwable occurred)called when close session.protected voidlogSqlClose(TgSessionTxLog txLog, TgSessionSqlLog sqlLog, java.lang.Throwable occurred)called when SQL result close.protected voidlogSqlEnd(TgSessionTxLog txLog, TgSessionSqlLog sqlLog, java.lang.Throwable occurred)called when SQL execute end.protected voidlogSqlExplain(int sqlId, int ssId, TsurugiSessionTxFileLogWriter writer, IoSupplier<TgStatementMetadata> explainSupplier)output SQL explain.protected <R> voidlogSqlRead(TgSessionTxLog txLog, TgSessionSqlLog sqlLog, TsurugiQueryResult<R> result, R record)called when SQL read.protected <R> voidlogSqlReadException(TgSessionTxLog txLog, TgSessionSqlLog sqlLog, TsurugiQueryResult<R> result, java.lang.Throwable occurred)called when occurs exception SQL read.protected voidlogSqlStart(TgSessionTxLog txLog, TgSessionSqlLog sqlLog)called when SQL execute start.protected voidlogSqlStartException(TgSessionTxLog txLog, TgSessionSqlLog sqlLog, java.lang.Throwable occurred)called when occurs exception SQL execute start.protected voidlogTmExecuteException(TgSessionTxLog txLog, java.lang.Throwable occurred)called when occurs transactionManager execute error.protected voidlogTmExecuteRetry(TgSessionTxLog txLog, java.lang.Exception cause, TgTmTxOption nextTmOption)called when transactionManager execute retry.protected voidlogTransactionClose(TgSessionTxLog txLog, java.lang.Throwable occurred)called when transaction close.protected voidlogTransactionCommitEnd(TgSessionTxLog txLog, TgCommitOption commitOption, java.lang.Throwable occurred)called when commit end.protected voidlogTransactionCommitStart(TgSessionTxLog txLog, TgCommitOption commitOption)called when commit start.protected voidlogTransactionRollbackEnd(TgSessionTxLog txLog, java.lang.Throwable occurred)called when rollback end.protected voidlogTransactionRollbackStart(TgSessionTxLog txLog)called when rollback start.protected voidlogTransactionSqlEnd(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 voidlogTransactionSqlStart(TsurugiTransaction.TgTxMethod method, TgSessionTxLog txLog, TgSessionTxLog.TgSessionTxExecuteLog exLog, TsurugiSql ps, java.lang.Object parameter)called when execute SQL start.protected voidlogTransactionStart(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, logTransactionCommitEnd, logTransactionCommitStart, 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:TsurugiSessionTxLoggercalled when create SQL definition.- Overrides:
logCreateSqlStatementin classTsurugiSessionTxLogger- Parameters:
ps- SQL definition
-
logTransactionStart
protected void logTransactionStart(TgSessionTxLog txLog)
Description copied from class:TsurugiSessionTxLoggercalled when transaction start.- Overrides:
logTransactionStartin 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.IOExceptioncreate 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:TsurugiSessionTxLoggercalled when get transactionId.- Overrides:
logLowTransactionGetStartin classTsurugiSessionTxLogger- Parameters:
txLog- transaction log
-
logLowTransactionGetEnd
protected void logLowTransactionGetEnd(TgSessionTxLog txLog, java.lang.String transactionId, java.lang.Throwable occurred)
Description copied from class:TsurugiSessionTxLoggercalled when get transactionId.- Overrides:
logLowTransactionGetEndin 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:TsurugiSessionTxLoggercalled when execute SQL start.- Overrides:
logTransactionSqlStartin 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:TsurugiSessionTxLoggercalled when execute SQL end.- Overrides:
logTransactionSqlEndin 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:TsurugiSessionTxLoggercalled when SQL execute start.- Overrides:
logSqlStartin 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:TsurugiSessionTxLoggercalled when occurs exception SQL execute start.- Overrides:
logSqlStartExceptionin 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:TsurugiSessionTxLoggercalled when SQL read.- Overrides:
logSqlReadin 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:TsurugiSessionTxLoggercalled when occurs exception SQL read.- Overrides:
logSqlReadExceptionin 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:TsurugiSessionTxLoggercalled when SQL execute end.- Overrides:
logSqlEndin classTsurugiSessionTxLogger- Parameters:
txLog- transaction logsqlLog- SQL logoccurred- exception
-
logSqlClose
protected void logSqlClose(TgSessionTxLog txLog, TgSessionSqlLog sqlLog, java.lang.Throwable occurred)
Description copied from class:TsurugiSessionTxLoggercalled when SQL result close.- Overrides:
logSqlClosein classTsurugiSessionTxLogger- Parameters:
txLog- transaction logsqlLog- SQL logoccurred- exception
-
logTransactionCommitStart
protected void logTransactionCommitStart(TgSessionTxLog txLog, TgCommitOption commitOption)
Description copied from class:TsurugiSessionTxLoggercalled when commit start.- Overrides:
logTransactionCommitStartin classTsurugiSessionTxLogger- Parameters:
txLog- transaction logcommitOption- commit option
-
logTransactionCommitEnd
protected void logTransactionCommitEnd(TgSessionTxLog txLog, TgCommitOption commitOption, java.lang.Throwable occurred)
Description copied from class:TsurugiSessionTxLoggercalled when commit end.- Overrides:
logTransactionCommitEndin classTsurugiSessionTxLogger- Parameters:
txLog- transaction logcommitOption- commit optionoccurred- exception
-
logTransactionRollbackStart
protected void logTransactionRollbackStart(TgSessionTxLog txLog)
Description copied from class:TsurugiSessionTxLoggercalled when rollback start.- Overrides:
logTransactionRollbackStartin classTsurugiSessionTxLogger- Parameters:
txLog- transaction log
-
logTransactionRollbackEnd
protected void logTransactionRollbackEnd(TgSessionTxLog txLog, java.lang.Throwable occurred)
Description copied from class:TsurugiSessionTxLoggercalled when rollback end.- Overrides:
logTransactionRollbackEndin classTsurugiSessionTxLogger- Parameters:
txLog- transaction logoccurred- exception
-
logTmExecuteException
protected void logTmExecuteException(TgSessionTxLog txLog, java.lang.Throwable occurred)
Description copied from class:TsurugiSessionTxLoggercalled when occurs transactionManager execute error.- Overrides:
logTmExecuteExceptionin classTsurugiSessionTxLogger- Parameters:
txLog- transaction logoccurred- exception
-
logTmExecuteRetry
protected void logTmExecuteRetry(TgSessionTxLog txLog, java.lang.Exception cause, TgTmTxOption nextTmOption)
Description copied from class:TsurugiSessionTxLoggercalled when transactionManager execute retry.- Overrides:
logTmExecuteRetryin classTsurugiSessionTxLogger- Parameters:
txLog- transaction logcause- retry exceptionnextTmOption- next transaction option
-
logTransactionClose
protected void logTransactionClose(TgSessionTxLog txLog, java.lang.Throwable occurred)
Description copied from class:TsurugiSessionTxLoggercalled when transaction close.- Overrides:
logTransactionClosein 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:TsurugiSessionTxLoggercalled when close session.- Overrides:
logSessionClosein classTsurugiSessionTxLogger- Parameters:
session- sessionoccurred- exception
-
-