@@ -40,7 +40,7 @@ class LinkChecker(private val root: Path) {
4040 .filter { it.second.second.first != 200 }
4141 .toList()
4242 // todo remove
43- println ( " filePos2uriCheck = $filePos2uriCheck " )
43+ logger.debug { " filePos2uriCheck = $filePos2uriCheck " }
4444 return filePos2uriCheck
4545 .associateBy(
4646 { " ${it.first.first} :${it.first.second} " },
@@ -59,6 +59,8 @@ class LinkChecker(private val root: Path) {
5959 }
6060
6161 companion object {
62+ private val logger = mu.KotlinLogging .logger {}
63+
6264 /* *
6365 * https://stackoverflow.com/a/45690571
6466 */
@@ -104,8 +106,7 @@ class LinkChecker(private val root: Path) {
104106 val request = HttpRequest .newBuilder(this ).GET ().build()
105107 // todo Cache
106108 return try {
107- // todo Logging
108- println (" Check: $this " )
109+ logger.info(" Check: $this " )
109110 val response = client.send(request, HttpResponse .BodyHandlers .discarding())
110111 when (response.statusCode()) {
111112 // Redirects: extract new location
@@ -128,16 +129,15 @@ class LinkChecker(private val root: Path) {
128129
129130 ? : 500
130131
131- // todo Logging
132- println (" Await: $await ms" )
132+ logger.debug(" Await: $await ms" )
133133 Thread .sleep(await)
134134 check(client)
135135 }
136136
137137 else -> response.statusCode() to response.uri()
138138 }
139139 } catch (e: Exception ) {
140- // todo Logging
140+ logger.error(e) { " Handle error on checking $this " }
141141 - 1 to URI .create(" http://host?message=${e.message?.replace(" " , " %20" )} " )
142142 }
143143 }
0 commit comments