Skip to content

Commit e99a53d

Browse files
committed
Refactor logging config structure
1 parent c45fb9e commit e99a53d

File tree

7 files changed

+14
-14
lines changed

7 files changed

+14
-14
lines changed

.env

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
LOG_REQUEST=true
1+
LOG_HTTP=true

src/main/resources/application.conf

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ server {
44

55
port = 8080
66
port = ${?APP_PORT}
7+
}
78

8-
log {
9-
request-header = false
10-
request-header = ${?LOG_REQUEST}
9+
log {
10+
http-header = false
11+
http-header = ${?LOG_HTTP}
1112

12-
request-body = false
13-
request-body = ${?LOG_REQUEST}
14-
}
15-
}
13+
http-body = false
14+
http-body = ${?LOG_HTTP}
15+
}

src/main/scala/com/hhandoko/realworld/Server.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ object Server {
3030
}
3131

3232
private[this] def loggedRoutes[F[_]: ConcurrentEffect](conf: Config, routes: HttpRoutes[F]): HttpRoutes[F] =
33-
Logger.httpRoutes(conf.server.log.requestHeader, conf.server.log.requestBody) { routes }
33+
Logger.httpRoutes(conf.log.httpHeader, conf.log.httpBody) { routes }
3434

3535
private[this] def server[F[_]: ConcurrentEffect: ContextShift: Timer](
3636
config: Config,
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
package com.hhandoko.realworld.config
22

3-
final case class Config(server: ServerConfig)
3+
final case class Config(server: ServerConfig, log: LogConfig)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package com.hhandoko.realworld.config
2+
3+
final case class LogConfig(httpHeader: Boolean, httpBody: Boolean)

src/main/scala/com/hhandoko/realworld/config/RequestLogConfig.scala

-3
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
package com.hhandoko.realworld.config
22

3-
final case class ServerConfig(host: String, port: Int, log: RequestLogConfig)
3+
final case class ServerConfig(host: String, port: Int)

0 commit comments

Comments
 (0)