Skip to content
/ spy Public

Pretty printed human readable String inspection of Scala objects

License

Notifications You must be signed in to change notification settings

guardian/spy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spy spy Scala version support

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 += "com.gu" %% "spy" % "x.x.x"

Example

import com.gu.spy._
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"))
println(user.spy)

where println(user.spy) outputs

User
  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))

Credits

About

Pretty printed human readable String inspection of Scala objects

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

 
 
 

Languages