Some useful extra stuff for Scala developers
group-id: net.kolotyluk
artifact-id: scala-extras_2.11
Search Maven Central for more details
import net.kolotyluk.scala.LogbackLogging
object Main extends App with LogbackLogging {
logger.info("Hello Scala Extras")
}
The main purpose of these extras is to simplify some of the basic trivial boilerplat stuff when writing Scala code
Traits are used to add basical functionality, such as logging, configuration, etc. to your code.
Adds the environment property to your code.
import net.kolotyluk.scala.Environment
import net.kolotyluk.scala.LogbackLogging
object Main extends App with LogbackLogging wtih Environment {
logger.info("USERNAME = " + environment.get("USERNAME"))
}
Logs the system environment variables. This can be useful in troubleshooting situations, expecially when environment variable settings affect your code.
Adds the logger property to your code.
The most common logging is the SLF4J interface with a Logback implementation.
import net.kolotyluk.scala.LogbackLogging
object Main extends App with LogbackLogging {
logger.info("Hello Scala Extras")
}
Logs the Logback configuration. This can be useful in troubleshooting situations, expecially when you are troubleshooting logging issues.
Adds the config property to your code.
By default, the Typesafe Config includes all the Java system properties, so you don't need a separate trait for that.
import net.kolotyluk.scala.Environment
import net.kolotyluk.scala.Typesafe.Configuration
import net.kolotyluk.scala.LogbackLogging
object Main extends App with LogbackLogging wtih Environment with Configuration {
logger.info("USERNAME = " + environment.get("USERNAME"))
logger.info("user.name = " + config.getString("user.name"))
}
Logs the configuration settings. This can be useful in troubleshooting situations, expecially when configurations settings affect your code.