The Blindsight is a scala logging API based on SLF4J API, Logback and logstach logback encoder. It delegates logging to the SLF4J API and doesn’t configure or manage the SFL4J implementation. It use macro to get the source code information and support cross-thread context.

1 Getting Started

First add the following repository for dependency ivy"com.tersesystems.blindsight::blindsight-logstash:1.0.1".

1
2
3
4
5
6
7
import coursier.maven.MavenRepository

def repositories = super.repositories ++ Seq(
  MavenRepository(
    "https://dl.bintray.com/tersesystems/maven"
  )
)

Then import the type import com.tersesystems.blindsight.LoggerFactory.

Finally create a logger: val logger = LoggerFactory.getLogger and use it for logging. The default logger name is the outside class/object name. You can also use LoggerFactory.getLogger(getClass). If using a string, the string must follow the valid package pattern such as app.myClass. The default LoggerResolver is class-based logging.

2 SFL4J API

The call logger.info("I am an SLF4J-like logger") is implemented as

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
val infoMethod: InfoMethod = logger.info
infoMethod.apply(Message("I am an SLF4J-like logger"))

// rough implementation
class InfoMethod {
  def apply(msg: => Message) {
    if (slf4jLogger.isInfoEnabled()) {
       slf4jLogger.info(msg.toString)
    }
  }
}

Blindsight generalizes the concepts of Marker, Messange and Argument.