Skip to content

Commit 508561c

Browse files
committed
added logging functionality
1 parent bf6f886 commit 508561c

File tree

4 files changed

+31
-19
lines changed

4 files changed

+31
-19
lines changed

kotlin/services/apigateway/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ dependencies {
3636
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
3737
implementation("com.fasterxml.jackson.core:jackson-databind:2.14.2")
3838
implementation("com.google.code.gson:gson:2.10")
39+
implementation("org.slf4j:slf4j-api:2.0.15")
40+
implementation("org.slf4j:slf4j-simple:2.0.15")
3941
}
4042
tasks.withType<KotlinCompile> {
4143
kotlinOptions.jvmTarget = "17"

kotlin/services/apigateway/src/test/kotlin/APIGatewayTest.kt

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@ import org.junit.jupiter.api.Test
1919
import org.junit.jupiter.api.TestInstance
2020
import org.junit.jupiter.api.TestMethodOrder
2121
import java.util.Random
22+
import org.slf4j.Logger
23+
import org.slf4j.LoggerFactory
2224

2325
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
2426
@TestMethodOrder(OrderAnnotation::class)
2527
class APIGatewayTest {
28+
private val logger: Logger = LoggerFactory.getLogger(APIGatewayTest::class.java)
2629
lateinit var apiGatewayClient: ApiGatewayClient
2730
private var restApiId = ""
2831
private var httpMethod = ""
@@ -43,49 +46,34 @@ class APIGatewayTest {
4346
httpMethod = values.httpMethod.toString()
4447
restApiName = values.restApiName.toString() + randomNum
4548
stageName = values.stageName.toString()
46-
47-
/*
48-
val input: InputStream = this.javaClass.getClassLoader().getResourceAsStream("config.properties")
49-
val prop = Properties()
50-
51-
// load the properties file.
52-
prop.load(input)
53-
54-
// Populate the data members required for all tests
55-
restApiId = prop.getProperty("restApiId")
56-
resourceId = prop.getProperty("resourceId")
57-
httpMethod = prop.getProperty("httpMethod")
58-
restApiName = prop.getProperty("restApiName")
59-
stageName = prop.getProperty("stageName")
60-
*/
6149
}
6250

6351
@Test
6452
@Order(1)
6553
fun createRestApiTest() = runBlocking {
6654
newApiId = createAPI(restApiId).toString()
67-
println("Test 2 passed")
55+
logger.info("Test 1 passed")
6856
}
6957

7058
@Test
7159
@Order(2)
7260
fun getDeploymentsTest() = runBlocking {
7361
getAllDeployments(newApiId)
74-
println("Test 4 passed")
62+
logger.info("Test 2 passed")
7563
}
7664

7765
@Test
7866
@Order(3)
7967
fun getAllStagesTest() = runBlocking {
8068
getAllStages(newApiId)
81-
println("Test 5 passed")
69+
logger.info("Test 3 passed")
8270
}
8371

8472
@Test
8573
@Order(4)
8674
fun deleteRestApi() = runBlocking {
8775
deleteAPI(newApiId)
88-
println("Test 6 passed")
76+
logger.info("Test 4 passed")
8977
}
9078

9179
private suspend fun getSecretValues(): String {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<configuration>
2+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
3+
<encoder>
4+
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n</pattern>
5+
</encoder>
6+
</appender>
7+
8+
<root level="info">
9+
<appender-ref ref="STDOUT"/>
10+
</root>
11+
</configuration>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<configuration>
2+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
3+
<encoder>
4+
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n</pattern>
5+
</encoder>
6+
</appender>
7+
8+
<root level="info">
9+
<appender-ref ref="STDOUT"/>
10+
</root>
11+
</configuration>

0 commit comments

Comments
 (0)