Skip to content

Commit

Permalink
Merge pull request #343 from Daenyth/patch-1
Browse files Browse the repository at this point in the history
Add a `LogLevel.fromString` method
  • Loading branch information
lorandszakacs authored Feb 10, 2021
2 parents 524ef33 + 56fc3a1 commit 88219e7
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ object LogLevel {
case object Debug extends LogLevel
case object Trace extends LogLevel

def fromString(s: String): Option[LogLevel] = s.toLowerCase match {
case "error" => Some(LogLevel.Error)
case "warn" => Some(LogLevel.Warn)
case "info" => Some(LogLevel.Info)
case "debug" => Some(LogLevel.Debug)
case "trace" => Some(LogLevel.Trace)
case "loglevel.error" => Some(LogLevel.Error)
case "loglevel.warn" => Some(LogLevel.Warn)
case "loglevel.info" => Some(LogLevel.Info)
case "loglevel.debug" => Some(LogLevel.Debug)
case "loglevel.trace" => Some(LogLevel.Trace)
case _ => None
}

implicit val logLevelShow: Show[LogLevel] = Show.show[LogLevel] {
case Error => "LogLevel.Error"
case Warn => "LogLevel.Warn"
Expand Down

0 comments on commit 88219e7

Please sign in to comment.