Skip to content

Instantly share code, notes, and snippets.

@jschwietert
Created July 20, 2017 19:07
Show Gist options
  • Save jschwietert/91537e603377e84e459c928b625b4b79 to your computer and use it in GitHub Desktop.
Save jschwietert/91537e603377e84e459c928b625b4b79 to your computer and use it in GitHub Desktop.
Scaled down Logger implementation of VictorOps unified logging.
trait Logger {
final protected def format(t: Throwable, msg: => String, variables: LogVariables): String
final def format(msg: => String, variables: LogVariable*): String
final def info(msg: => String, variables: LogVariable*): Unit = if (isInfoEnabled) logInfo(format(msg, variables))
// ...
final def error(msg: => String, variables: LogVariable*): Unit = if (isErrorEnabled) logError(format(msg, variables))
final def error(t: Throwable, msg: => String, variables: LogVariable*) = if (isErrorEnabled) logError(t, format(t, msg, variables))
// Here down requires implementation per Logger type: ClassLogger & ActorLogger
def getName: String
def classLogVariables: LogVariables
def isInfoEnabled: Boolean
// ...
def isErrorEnabled: Boolean
protected def logInfo(msg: String): Unit
// ...
protected def logError(msg: String): Unit
protected def logError(t: Throwable, msg: String): Unit
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment