mirror of
https://github.com/tursom/TursomServer.git
synced 2025-01-06 10:20:14 +08:00
增强日志
This commit is contained in:
parent
e41da3463a
commit
e4c6b5657e
@ -61,7 +61,7 @@ fun configureLogbackDirectly(logDir: String, filePrefix: String) {
|
||||
|
||||
val defaultColorfulPattern = LogbackPattern.make {
|
||||
+color { green }(+date)["yyyy-MM-dd HH:mm:ss.SSS"] + " " +
|
||||
+color { magenta }("[${+thread}]") + " " +
|
||||
+color { magenta }("[${+thread.right(15, 15)}]") + " " +
|
||||
+color { highlight }(+level.left(5)) + " " +
|
||||
+color { cyan }("[${+logger["20"].right(20, 20)}]") + " - " +
|
||||
+color { highlight }(+message) + " " +
|
||||
|
@ -38,10 +38,13 @@ open class RoutedHttpHandler(
|
||||
addRouter(target ?: this)
|
||||
}
|
||||
|
||||
override fun handle(content: HttpContent) = if (content is MutableHttpContent) {
|
||||
handle(content, getHandler(content, content.method, content.uri))
|
||||
} else {
|
||||
handle(content, getHandler(content.method, content.uri).first?.second)
|
||||
override fun handle(content: HttpContent) {
|
||||
log?.debug("{}: {} {}", content.clientIp, content.method, content.uri)
|
||||
if (content is MutableHttpContent) {
|
||||
handle(content, getHandler(content, content.method, content.uri))
|
||||
} else {
|
||||
handle(content, getHandler(content.method, content.uri).first?.second)
|
||||
}
|
||||
}
|
||||
|
||||
open fun handle(content: HttpContent, handler: ((HttpContent) -> Unit)?) {
|
||||
|
@ -24,6 +24,7 @@ open class AsyncRoutedHttpHandler(
|
||||
protected val asyncRouterMap: HashMap<String, Router<Pair<Any?, suspend (HttpContent) -> Unit>>> = HashMap()
|
||||
|
||||
override fun handle(content: HttpContent) {
|
||||
log?.debug("{}: {} {}", content.clientIp, content.method, content.uri)
|
||||
if (content is MutableHttpContent) {
|
||||
val handler = getAsyncHandler(content, content.method, content.uri)
|
||||
if (handler != null) GlobalScope.launch {
|
||||
@ -194,8 +195,9 @@ open class AsyncRoutedHttpHandler(
|
||||
}
|
||||
}
|
||||
val mapping = handler::class.java.getAnnotation(Mapping::class.java)?.route ?: arrayOf("")
|
||||
member.annotations.forEach { annotation ->
|
||||
val (routes, router) = getAsyncRoutes(annotation) ?: return@forEach
|
||||
member.annotations.forEach route@{ annotation ->
|
||||
val (routes, router) =
|
||||
getAsyncRoutes(annotation) ?: return@route
|
||||
@Suppress("DuplicatedCode")
|
||||
routes.forEach { route ->
|
||||
if (mapping.isEmpty()) {
|
||||
@ -220,7 +222,7 @@ open class AsyncRoutedHttpHandler(
|
||||
|
||||
companion object {
|
||||
private val log = try {
|
||||
LoggerFactory.getLogger(RoutedHttpHandler::class.java)
|
||||
LoggerFactory.getLogger(AsyncRoutedHttpHandler::class.java)
|
||||
} catch (e: Throwable) {
|
||||
null
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user