guardian / spy   0.1.1

Apache License 2.0 GitHub

Pretty printed human readable String inspection of Scala objects

Scala versions: 2.13

spy Maven Central

Library for Scala 2.13+ projects for pretty printing case classes with field names in hierarchical tree format. Useful for debugging purposes as it gives human readable representation of case classes. Provides .spy extension method for any object.

User guide

Works only with Scala 2.13+

libraryDependencies += "" %% "spy" % "x.x.x"


case class Address(street: String, city: String, planet: String, country: String)
case class User(name: String, age: Int, address: Address)
val user = User("Jean-Luc Picard", 79, Address("Starfleet", "San Francisco", "Earth", "United Federation of Planets"))

where println(user.spy) outputs

  name: Jean-Luc Picard
  age: 79
  address: Address
    street: Starfleet
    city: San Francisco
    planet: Earth
    country: United Federation of Planets

as opposed to usual println(user) output

User(Jean-Luc Picard,79,Address(Starfleet,San Francisco,Earth,United Federation of Planets))