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