Indent while running a closure
authorChristos KK Loverdos <loverdos@gmail.com>
Thu, 1 Mar 2012 12:45:13 +0000 (14:45 +0200)
committerChristos KK Loverdos <loverdos@gmail.com>
Thu, 1 Mar 2012 12:45:13 +0000 (14:45 +0200)
src/main/scala/gr/grnet/aquarium/util/ContextualLogger.scala

index 3e7891e..07544c8 100644 (file)
@@ -140,6 +140,12 @@ final class ContextualLogger(val logger: Logger, fmt: String, args: Any*) {
     _nesting = _nesting - 1
     this
   }
+  
+  def withIndent[A](f: => A): Unit = {
+    import com.ckkloverdos.maybe.effect
+    this.indent()
+    effect(f){}{unindent()}
+  }
 
   def debug(fmt: String, args: Any*): Unit = {
     if(logger.isDebugEnabled) {