rmgk / logging Edit

I needed to do some logging. Making this was simpler than reusing something existing. Maybe I should start doing Javascript.

Version Matrix


Sometimes, I want to log some text.

Sometimes, I want to log with levels.

Sometimes, I want to log with tags.

Sometimes, I want to log with source lines.

But never do I want to log with XML.


This is a very simple logging library, intended as something more principled and structured than just println, but about as simple to set up. It provides some features such as tags, levels, and file and line information, but not much more is built in.

The philosophy is, that simple logging does not need configuration files. And for complex logging configuration files are too limiting and complicated. Instead, this logger provides a simple but well-structured starting point which can grow together with the application.


resolvers += Resolver.bintrayRepo("rmgk", "maven"),
libraryDependencies += "de.rmgk" %%% "logging" % "0.1.0"


The basic interface provides the usual logging methods logging with different levels.

import de.rmgk.logging.{Logger, Level}

val log = Logger()
// or
val log = Logger(tag = "Added to the output", level = Level.Debug)


Recommended usage and configuration is to create your own little libraries of loggers, which can be centrally configured, and use them as you see fit.

import de.rmgk.logging.{Level, Logger}

object Log {
  val common: Logger = Logger(tag = "", level = Level.Trace)
  val Tool: Logger = common.copy(tag = "Tool", level = Level.Info)
  val Main: Logger = common
  val Web: Logger = common.copy(tag = "Web")
  val Store: Logger = common.copy(tag = "IO")
  val Server: Logger = common.copy(tag = "Serv", logPrinter = Logger.tracing)

Log.Web.warn("download failed")

object Server {
  import Log.{Server => log}
  log.info("This is the server logger")

This will print:

Warn : download failed [Web]
This is the server logger [Serv].(Example.scala:24)

The info level does not have a prefix by default, use it to talk to your users.


The server output has the file and line number attached, this results in clickable links if used inside IntelliJ.

Custom Formatting

Creating a Logger takes a LogPrinter parameter, see DefaultLogPrinter for the default implementation, and feel free to implement your own custom formatting and output needs.


Issues and pull request welcome.

I assume that some more flexible configuration will be needed at some point, feel free to contribute usecases.