Improve error handling
This commit is contained in:
parent
87bd780f9f
commit
e6a8150483
7 changed files with 78 additions and 62 deletions
|
|
@ -9,10 +9,15 @@ import zio.http.codec.*
|
|||
import zio.http.codec.PathCodec.path
|
||||
import zio.http.endpoint.openapi.OpenAPIGen
|
||||
import zio.http.endpoint.openapi.SwaggerUI
|
||||
import zio.logging.ConsoleLoggerConfig
|
||||
import zio.logging.LogColor
|
||||
import zio.logging.LogFilter
|
||||
import zio.logging.LogFormat.*
|
||||
import zio.logging.consoleLogger
|
||||
import zio.schema.codec.JsonCodec.ExplicitConfig
|
||||
|
||||
import lu.foyer.clients.*
|
||||
import lu.foyer.contracts.*
|
||||
import zio.schema.codec.JsonCodec.ExplicitConfig
|
||||
|
||||
object HttpServer:
|
||||
|
||||
|
|
@ -28,10 +33,21 @@ object HttpServer:
|
|||
++ SwaggerUI.routes("docs" / "openapi", openAPI)
|
||||
|
||||
object App extends ZIOAppDefault:
|
||||
private val logFormat =
|
||||
label("timestamp", timestamp.fixed(32)).color(LogColor.BLUE) |-|
|
||||
label("level", level.fixed(5)).highlight |-|
|
||||
label("thread", fiberId).color(LogColor.WHITE) |-|
|
||||
label("message", quoted(line)).highlight |-|
|
||||
cause
|
||||
|
||||
override val bootstrap = CodecConfig.configLayer(
|
||||
CodecConfig(explicitNulls = ExplicitConfig(encoding = false, decoding = false))
|
||||
)
|
||||
val logFilter = LogFilter.LogLevelByNameConfig(LogLevel.Debug)
|
||||
|
||||
override val bootstrap =
|
||||
Runtime.removeDefaultLoggers >>>
|
||||
consoleLogger(ConsoleLoggerConfig(logFormat, logFilter)) >>>
|
||||
CodecConfig.configLayer(
|
||||
CodecConfig(explicitNulls = ExplicitConfig(encoding = false, decoding = false))
|
||||
)
|
||||
|
||||
val app =
|
||||
for
|
||||
|
|
@ -55,3 +71,4 @@ object App extends ZIOAppDefault:
|
|||
PremiumServiceImpl.layer,
|
||||
EmployeeServiceImpl.layer
|
||||
)
|
||||
end App
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue