Search in sources :

Example 1 with AbstractJdbcLogger

use of org.seasar.doma.jdbc.AbstractJdbcLogger in project sandbox by irof.

the class AppConfig method getJdbcLogger.

@Override
public JdbcLogger getJdbcLogger() {
    // 無名クラスじゃダメな理由として、このメソッド呼ばれるたびにインスタンスつくるのもどうなのというのもある。
    return new AbstractJdbcLogger<Level>(Level.INFO) {

        @Override
        protected void log(Level level, String callerClassName, String callerMethodName, Throwable throwable, Supplier<String> messageSupplier) {
            LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
            Logger logger = loggerContext.getLogger(callerClassName);
            int levelInt = Level.toLocationAwareLoggerInteger(level);
            logger.log(null, callerClassName, levelInt, messageSupplier.get(), null, null);
        }

        @Override
        protected void logTransactionBegun(String callerClassName, String callerMethodName, String transactionId, Level level, Supplier<String> messageSupplier) {
            super.logTransactionBegun(callerClassName, callerMethodName, transactionId, Level.DEBUG, messageSupplier);
        }

        @Override
        protected void logTransactionEnded(String callerClassName, String callerMethodName, String transactionId, Level level, Supplier<String> messageSupplier) {
            super.logTransactionEnded(callerClassName, callerMethodName, transactionId, Level.DEBUG, messageSupplier);
        }
    };
}
Also used : Level(ch.qos.logback.classic.Level) Supplier(java.util.function.Supplier) JdbcLogger(org.seasar.doma.jdbc.JdbcLogger) Logger(ch.qos.logback.classic.Logger) AbstractJdbcLogger(org.seasar.doma.jdbc.AbstractJdbcLogger) AbstractJdbcLogger(org.seasar.doma.jdbc.AbstractJdbcLogger) LoggerContext(ch.qos.logback.classic.LoggerContext)

Aggregations

Level (ch.qos.logback.classic.Level)1 Logger (ch.qos.logback.classic.Logger)1 LoggerContext (ch.qos.logback.classic.LoggerContext)1 Supplier (java.util.function.Supplier)1 AbstractJdbcLogger (org.seasar.doma.jdbc.AbstractJdbcLogger)1 JdbcLogger (org.seasar.doma.jdbc.JdbcLogger)1