Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix LoggingConfig #320

Merged
merged 4 commits into from
Jul 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion client/src/main/scala/skuber/api/client/LoggingConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package skuber.api.client
*/

import LoggingConfig.loggingEnabled
import scala.util.{Failure, Success, Try}

case class LoggingConfig(
logConfiguration: Boolean=loggingEnabled("config", true), // outputs configuration on initialisation)
Expand All @@ -22,7 +23,12 @@ case class LoggingConfig(

object LoggingConfig {
private def loggingEnabled(logEventType: String, fallback: Boolean) : Boolean= {
sysProps.get(s"skuber.log.$logEventType").map(_ => true).getOrElse(fallback)
sysProps.get(s"skuber.log.$logEventType").map {
value => Try(value.toBoolean) match {
case Success(value) => value
case Failure(_) => throw new IllegalArgumentException(s"argument skuber.log.$logEventType:$value can't be parsed to boolean")
}
}.getOrElse(fallback)
}
}