Skip to content

Commit 654f1b6

Browse files
committed
Chapter 14. Better program loggerrr
1 parent 56cd5b6 commit 654f1b6

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1-
def log desc, &block
2-
# your code here
1+
$nesting_depth = 0
2+
3+
def better_log desc, &block
4+
puts ' ' * $nesting_depth + "Beginning \"#{desc}\"..."
5+
$nesting_depth += 1
6+
result = block.call
7+
$nesting_depth -= 1
8+
puts ' ' * $nesting_depth + "...\"#{desc}\" finished, returning: #{result}"
39
end

0 commit comments

Comments
 (0)