Skip to content

Commit

Permalink
fix: fix breaking code
Browse files Browse the repository at this point in the history
BREAKING CHANGE: More details oshai/kotlin-logging#264
  • Loading branch information
sum1re committed Aug 25, 2024
1 parent 019956b commit d57de87
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 24 deletions.
6 changes: 3 additions & 3 deletions src/main/kotlin/com/neo/caption/ocr/common/AppAnnotation.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.neo.caption.ocr.common

import io.github.oshai.KLogger
import io.github.oshai.KotlinLogging
import io.github.oshai.kotlinlogging.KLogger
import io.github.oshai.kotlinlogging.KotlinLogging
import org.jetbrains.exposed.exceptions.ExposedSQLException
import org.springframework.cache.annotation.CacheConfig
import org.springframework.core.annotation.AliasFor
Expand All @@ -26,7 +26,7 @@ annotation class Slf4j {

companion object {
@Suppress("UnusedReceiverParameter")
val <reified T> T.log: KLogger
val <reified T> T.logging: KLogger
inline get() = KotlinLogging.logger(T::class.java.name)
}

Expand Down
12 changes: 6 additions & 6 deletions src/main/kotlin/com/neo/caption/ocr/common/ExceptionHandler.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.neo.caption.ocr.common

import com.neo.caption.ocr.common.Slf4j.Companion.log
import com.neo.caption.ocr.common.Slf4j.Companion.logging
import com.neo.caption.ocr.domain.ErrorResponse
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler
import org.springframework.cache.Cache
Expand All @@ -16,19 +16,19 @@ import java.lang.reflect.Method
class CaffeineCacheErrorHandler : CacheErrorHandler {

override fun handleCacheGetError(exception: RuntimeException, cache: Cache, key: Any) {
log.error { "CacheError [option: GET, key: $key, cause: ${exception.cause}]" }
logging.error { "CacheError [option: GET, key: $key, cause: ${exception.cause}]" }
}

override fun handleCachePutError(exception: RuntimeException, cache: Cache, key: Any, value: Any?) {
log.error { "CacheError [option: PUT, key: $key, value: $value, cause: ${exception.cause}]" }
logging.error { "CacheError [option: PUT, key: $key, value: $value, cause: ${exception.cause}]" }
}

override fun handleCacheEvictError(exception: RuntimeException, cache: Cache, key: Any) {
log.error { "CacheError [option: EVICT, key: $key, cause: ${exception.cause}]" }
logging.error { "CacheError [option: EVICT, key: $key, cause: ${exception.cause}]" }
}

override fun handleCacheClearError(exception: RuntimeException, cache: Cache) {
log.error { "CacheError [option: CLEAR, cause: ${exception.cause}]" }
logging.error { "CacheError [option: CLEAR, cause: ${exception.cause}]" }
}

}
Expand Down Expand Up @@ -61,7 +61,7 @@ class RestExceptionHandler {
class AsyncExceptionHandler : AsyncUncaughtExceptionHandler {

override fun handleUncaughtException(ex: Throwable, method: Method, vararg params: Any) {
log.error { "async exception: [method: $method, params: $params, message: ${ex.stackTraceToString()}]" }
logging.error { "async exception: [method: $method, params: $params, message: ${ex.stackTraceToString()}]" }
throw ex
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/com/neo/caption/ocr/service/LoaderService.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.neo.caption.ocr.service

import com.neo.caption.ocr.common.CommonService
import com.neo.caption.ocr.common.Slf4j.Companion.log
import com.neo.caption.ocr.common.Slf4j.Companion.logging
import org.bytedeco.javacpp.Loader
import org.springframework.boot.autoconfigure.web.ServerProperties
import org.springframework.cache.annotation.Cacheable
Expand Down Expand Up @@ -63,13 +63,13 @@ class LoaderService(
} ?: emptyList()
)
}.getOrElse {
log.error(it) { "Application will exit because failed loading javacpp library" }
logging.error(it) { "Application will exit because failed loading javacpp library" }
exitProcess(-1)
}

private fun Class<*>.loading() {
Loader.load(this)
log.debug { "Loading class: $this" }
logging.debug { "Loading class: $this" }
}

}
8 changes: 4 additions & 4 deletions src/main/kotlin/com/neo/caption/ocr/support/AppInitialize.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.neo.caption.ocr.support
import com.neo.caption.ocr.common.COCR_BATCH_OCR_CHAIN
import com.neo.caption.ocr.common.COCR_PROJECT_CHAIN
import com.neo.caption.ocr.common.CommonProperties
import com.neo.caption.ocr.common.Slf4j.Companion.log
import com.neo.caption.ocr.common.Slf4j.Companion.logging
import com.neo.caption.ocr.module.app.AppConfigTable
import com.neo.caption.ocr.module.app.AppService
import com.neo.caption.ocr.module.liteflow.AstEdgeTable
Expand Down Expand Up @@ -38,9 +38,9 @@ class AppInitialize(
override fun run(args: ApplicationArguments?) {
loaderService.loadLib(opencv_java::class.java)
val system = loaderService.systemInformation()
log.debug { "System: [$system]" }
log.debug { "JavaCPP: [${loaderService.javacpp()}]" }
log.info {
logging.debug { "System: [$system]" }
logging.debug { "JavaCPP: [${loaderService.javacpp()}]" }
logging.info {
"""
|Caption OCR Tool service (v${appService.getAppInfoDto().version}) is ready!
|Open http://${system.ip}:${system.port} in your browser.
Expand Down
18 changes: 10 additions & 8 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ spring:
mvc:
converters:
preferred-json-mapper: jackson
throw-exception-if-no-handler-found: true
task:
execution:
pool:
Expand All @@ -31,15 +30,18 @@ spring:
servlet:
multipart:
enabled: false

liteflow:
enable: true
print-banner: false
parse-mode: parse_all_on_start

logging:
pattern:
dateformat: dd-MM-yyyy HH:mm:ss.SSS
dateformat:
dd-MM-yyyy HH:mm:ss.SSS
logback:
rollingpolicy:
max-history: 7
max-file-size: 4096KB
file-name-pattern: ${cocr.dir}/logs/%d{yyyy-MM-dd}.%i.log

liteflow:
enable: true
parse-on-start: true
print-banner: false
file-name-pattern: ./data/logs/%d{yyyy-MM-dd}.%i.log

0 comments on commit d57de87

Please sign in to comment.