diff -r 9a81a11be70e -r e71ae69c68c0 src/main/kotlin/de/uapcore/lightpit/DataSourceProvider.kt --- a/src/main/kotlin/de/uapcore/lightpit/DataSourceProvider.kt Sun Dec 12 18:16:46 2021 +0100 +++ b/src/main/kotlin/de/uapcore/lightpit/DataSourceProvider.kt Wed Dec 15 19:56:05 2021 +0100 @@ -38,7 +38,9 @@ * Provides access to the database. */ @WebListener -class DataSourceProvider : ServletContextListener, LoggingTrait { +class DataSourceProvider : ServletContextListener { + + private val logger = MyLogger() enum class Dialect { Postgres @@ -100,7 +102,7 @@ ) } val metaData = conn.metaData - logger().info( + logger.info( "Connections as {} to {}/{} ready to go.", metaData.userName, metaData.url, @@ -108,18 +110,18 @@ ) } } catch (ex: SQLException) { - logger().error("Checking database connection failed", ex) + logger.error("Checking database connection failed", ex) } } private fun retrieveDataSource(ctx: Context): DataSource? { return try { val ret = ctx.lookup(DS_JNDI_NAME) as DataSource - logger().info("Data source retrieved.") + logger.info("Data source retrieved.") ret } catch (ex: NamingException) { - logger().error("Data source {} not available.", DS_JNDI_NAME) - logger().error("Reason for the missing data source: ", ex) + logger.error("Data source {0} not available.", DS_JNDI_NAME) + logger.error("Reason for the missing data source: ", ex) null } } @@ -132,8 +134,8 @@ try { dialect = Dialect.valueOf(dbDialect) } catch (ex: IllegalArgumentException) { - logger().error( - "Unknown or unsupported database dialect {}. Defaulting to {}.", + logger.error( + "Unknown or unsupported database dialect {0}. Defaulting to {1}.", dbDialect, dialect ) @@ -141,22 +143,22 @@ } dataSource = try { - logger().debug("Trying to access JNDI context ...") + logger.debug("Trying to access JNDI context ...") val initialCtx: Context = InitialContext() val ctx = initialCtx.lookup("java:comp/env") as Context retrieveDataSource(ctx) } catch (ex: NamingException) { - logger().error("Cannot access JNDI resources.", ex) + logger.error("Cannot access JNDI resources.", ex) null } catch (ex: ClassCastException) { - logger().error("Cannot access JNDI resources.", ex) + logger.error("Cannot access JNDI resources.", ex) null } dataSource?.let { checkConnection(it, dbSchema) } sc.setAttribute(SC_ATTR_NAME, this) - logger().info("Database facade injected into ServletContext.") + logger.info("Database facade injected into ServletContext.") } override fun contextDestroyed(sce: ServletContextEvent?) {