Skip to content

Commit 348ae97

Browse files
committed
Http Log Level
Signed-off-by: akostiucenko <[email protected]>
1 parent d75e92d commit 348ae97

File tree

7 files changed

+27
-27
lines changed

7 files changed

+27
-27
lines changed

modules/admin-client/src/main/kotlin/jp/co/soramitsu/iroha2/AdminIroha2AsyncClient.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package jp.co.soramitsu.iroha2
22

3+
import io.ktor.client.plugins.logging.LogLevel
34
import jp.co.soramitsu.iroha2.model.IrohaUrls
45
import kotlinx.coroutines.future.future
56

@@ -9,9 +10,9 @@ import kotlinx.coroutines.future.future
910
@Suppress("unused")
1011
class AdminIroha2AsyncClient @JvmOverloads constructor(
1112
urls: List<IrohaUrls>,
12-
log: Boolean = false,
13+
httpLogLevel: LogLevel = LogLevel.NONE,
1314
credentials: String? = null,
14-
) : AdminIroha2Client(urls, log, credentials) {
15+
) : AdminIroha2Client(urls, httpLogLevel, credentials) {
1516

1617
/**
1718
* Send health check request

modules/admin-client/src/main/kotlin/jp/co/soramitsu/iroha2/AdminIroha2Client.kt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package jp.co.soramitsu.iroha2
22

33
import io.ktor.client.call.body
4+
import io.ktor.client.plugins.logging.LogLevel
45
import io.ktor.client.request.get
56
import io.ktor.client.request.setBody
67
import io.ktor.client.statement.HttpResponse
@@ -18,33 +19,33 @@ import java.net.URL
1819
@Suppress("unused")
1920
open class AdminIroha2Client(
2021
urls: List<IrohaUrls>,
21-
log: Boolean = false,
22+
httpLogLevel: LogLevel = LogLevel.NONE,
2223
credentials: String? = null,
2324
private val balancingHealthCheck: Boolean = true,
24-
) : Iroha2Client(urls, log, credentials) {
25+
) : Iroha2Client(urls, httpLogLevel, credentials) {
2526

2627
constructor(
2728
url: IrohaUrls,
28-
log: Boolean = false,
29+
httpLogLevel: LogLevel = LogLevel.NONE,
2930
credentials: String? = null,
3031
balancingHealthCheck: Boolean = true,
31-
) : this(mutableListOf(url), log, credentials, balancingHealthCheck)
32+
) : this(mutableListOf(url), httpLogLevel, credentials, balancingHealthCheck)
3233

3334
constructor(
3435
apiUrl: URL,
3536
peerUrl: URL,
36-
log: Boolean = false,
37+
httpLogLevel: LogLevel = LogLevel.NONE,
3738
credentials: String? = null,
3839
balancingHealthCheck: Boolean = true,
39-
) : this(IrohaUrls(apiUrl, peerUrl), log, credentials, balancingHealthCheck)
40+
) : this(IrohaUrls(apiUrl, peerUrl), httpLogLevel, credentials, balancingHealthCheck)
4041

4142
constructor(
4243
apiUrl: String,
4344
peerUrl: String,
44-
log: Boolean = false,
45+
httpLogLevel: LogLevel = LogLevel.NONE,
4546
credentials: String? = null,
4647
balancingHealthCheck: Boolean = true,
47-
) : this(URL(apiUrl), URL(peerUrl), log, credentials, balancingHealthCheck)
48+
) : this(URL(apiUrl), URL(peerUrl), httpLogLevel, credentials, balancingHealthCheck)
4849

4950
/**
5051
* Send metrics request

modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/client/Iroha2AsyncClient.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package jp.co.soramitsu.iroha2.client
22

3+
import io.ktor.client.plugins.logging.LogLevel
34
import jp.co.soramitsu.iroha2.generated.SignedTransaction
45
import jp.co.soramitsu.iroha2.model.IrohaUrls
56
import jp.co.soramitsu.iroha2.query.QueryAndExtractor
@@ -14,11 +15,11 @@ import java.util.concurrent.CompletableFuture
1415
@Suppress("unused")
1516
class Iroha2AsyncClient @JvmOverloads constructor(
1617
urls: List<IrohaUrls>,
17-
log: Boolean = false,
18+
httpLogLevel: LogLevel = LogLevel.NONE,
1819
credentials: String? = null,
1920
eventReadTimeoutInMills: Long = 250,
2021
eventReadMaxAttempts: Int = 10,
21-
) : Iroha2Client(urls, log, credentials, eventReadTimeoutInMills, eventReadMaxAttempts) {
22+
) : Iroha2Client(urls, httpLogLevel, credentials, eventReadTimeoutInMills, eventReadMaxAttempts) {
2223

2324
/**
2425
* Send a request to Iroha2 and extract payload.

modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/client/Iroha2Client.kt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import io.ktor.client.plugins.auth.Auth
1717
import io.ktor.client.plugins.auth.providers.BasicAuthCredentials
1818
import io.ktor.client.plugins.auth.providers.basic
1919
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
20+
import io.ktor.client.plugins.logging.LogLevel
2021
import io.ktor.client.plugins.logging.Logging
2122
import io.ktor.client.plugins.websocket.WebSockets
2223
import io.ktor.client.plugins.websocket.webSocket
@@ -81,7 +82,7 @@ import kotlin.coroutines.CoroutineContext
8182
@Suppress("unused")
8283
open class Iroha2Client(
8384
open val urls: List<IrohaUrls>,
84-
open val log: Boolean = false,
85+
open val httpLogLevel: LogLevel = LogLevel.NONE,
8586
open val credentials: String? = null,
8687
open val eventReadTimeoutInMills: Long = 250,
8788
open val eventReadMaxAttempts: Int = 10,
@@ -90,22 +91,22 @@ open class Iroha2Client(
9091

9192
constructor(
9293
url: IrohaUrls,
93-
log: Boolean = false,
94+
httpLogLevel: LogLevel = LogLevel.NONE,
9495
credentials: String? = null,
9596
eventReadTimeoutInMills: Long = 250,
9697
eventReadMaxAttempts: Int = 10,
97-
) : this(mutableListOf(url), log, credentials, eventReadTimeoutInMills, eventReadMaxAttempts)
98+
) : this(mutableListOf(url), httpLogLevel, credentials, eventReadTimeoutInMills, eventReadMaxAttempts)
9899

99100
constructor(
100101
apiUrl: URL,
101102
peerUrl: URL,
102-
log: Boolean = false,
103+
httpLogLevel: LogLevel = LogLevel.NONE,
103104
credentials: String? = null,
104105
eventReadTimeoutInMills: Long = 250,
105106
eventReadMaxAttempts: Int = 10,
106107
) : this(
107108
IrohaUrls(apiUrl, peerUrl),
108-
log,
109+
httpLogLevel,
109110
credentials,
110111
eventReadTimeoutInMills,
111112
eventReadMaxAttempts,
@@ -114,14 +115,14 @@ open class Iroha2Client(
114115
constructor(
115116
apiUrl: String,
116117
peerUrl: String,
117-
log: Boolean = true,
118+
httpLogLevel: LogLevel = LogLevel.NONE,
118119
credentials: String? = null,
119120
eventReadTimeoutInMills: Long = 250,
120121
eventReadMaxAttempts: Int = 10,
121122
) : this(
122123
URL(apiUrl),
123124
URL(peerUrl),
124-
log,
125+
httpLogLevel,
125126
credentials,
126127
eventReadTimeoutInMills,
127128
eventReadMaxAttempts,
@@ -145,8 +146,8 @@ open class Iroha2Client(
145146
open val client by lazy {
146147
HttpClient(CIO) {
147148
expectSuccess = true
148-
if (log) {
149-
install(Logging)
149+
install(Logging) {
150+
level = httpLogLevel
150151
}
151152
install(WebSockets)
152153
install(ContentNegotiation) {

modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/ExampleTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class ExampleTest {
2626
this.genesis = DefaultGenesis()
2727
}.also { it.start() }
2828

29-
val client = Iroha2Client(container.getApiUrl(), container.getP2pUrl(), true)
29+
val client = Iroha2Client(container.getApiUrl(), container.getP2pUrl())
3030

3131
val domainId = "new_domain_name".asDomainId()
3232
client.sendTransaction {

modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/GenesisTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class GenesisTest : IrohaTest<Iroha2Client>() {
3535
this.genesisPath = path
3636
}.also { it.start() }
3737

38-
val client = Iroha2Client(container.getApiUrl(), container.getP2pUrl(), true)
38+
val client = Iroha2Client(container.getApiUrl(), container.getP2pUrl())
3939
client.checkAliceAndBobExists()
4040
}
4141

modules/test-tools/src/main/kotlin/jp/co/soramitsu/iroha2/testengine/IrohaRunnerExtension.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,31 +111,27 @@ class IrohaRunnerExtension : InvocationInterceptor, BeforeEachCallback {
111111
setPropertyValue(properties, testInstance) {
112112
Iroha2Client(
113113
containers.map { IrohaUrls(it.getApiUrl(), it.getP2pUrl()) }.toMutableList(),
114-
true,
115114
).also { utilizedResources.add(it) }
116115
}
117116

118117
// inject `AdminIroha2Client` if it is declared in test class
119118
setPropertyValue(properties, testInstance) {
120119
AdminIroha2Client(
121120
containers.map { IrohaUrls(it.getApiUrl(), it.getP2pUrl()) }.toMutableList(),
122-
true,
123121
).also { utilizedResources.add(it) }
124122
}
125123

126124
// inject `Iroha2AsyncClient` if it is declared in test class
127125
setPropertyValue(properties, testInstance) {
128126
Iroha2AsyncClient(
129127
containers.map { IrohaUrls(it.getApiUrl(), it.getP2pUrl()) }.toMutableList(),
130-
true,
131128
).also { utilizedResources.add(it) }
132129
}
133130

134131
// inject `AdminIroha2AsyncClient` if it is declared in test class
135132
setPropertyValue(properties, testInstance) {
136133
AdminIroha2AsyncClient(
137134
containers.map { IrohaUrls(it.getApiUrl(), it.getP2pUrl()) }.toMutableList(),
138-
true,
139135
).also { utilizedResources.add(it) }
140136
}
141137

0 commit comments

Comments
 (0)