summaryrefslogtreecommitdiff
path: root/lib/chef/formatters
diff options
context:
space:
mode:
authorJohn Keiser <jkeiser@opscode.com>2014-04-30 10:44:31 -0700
committerJohn Keiser <jkeiser@opscode.com>2014-04-30 10:44:31 -0700
commit1947c989ced0604c763c9f149d8508a29629eadb (patch)
treeed11015d4d2a9fb5cb2faf7019640a3b678c5708 /lib/chef/formatters
parent826726718bbc9e36847bd36ed475f739fc296a48 (diff)
downloadchef-1947c989ced0604c763c9f149d8508a29629eadb.tar.gz
Print prefix to distinguish separate streams of output
Diffstat (limited to 'lib/chef/formatters')
-rw-r--r--lib/chef/formatters/base.rb32
1 files changed, 26 insertions, 6 deletions
diff --git a/lib/chef/formatters/base.rb b/lib/chef/formatters/base.rb
index 19bc24ddd2..c86a14e9eb 100644
--- a/lib/chef/formatters/base.rb
+++ b/lib/chef/formatters/base.rb
@@ -115,14 +115,26 @@ class Chef
# Make sure each line stays a unit even with threads sending output
semaphore.synchronize do
- # If we aren't printing to the same stream, or if start_line is true,
- # move to the next line.
- if options[:start_line] || @stream != options[:stream]
+ # If we aren't printing to the same stream, move to the next line
+ # and print the stream header (if any)
+ if @stream != options[:stream]
+ @stream = options[:stream]
+ if @line_started
+ @out.puts ''
+ end
+ if options[:name]
+ @out.print "#{(' ' * indent)}[#{options[:name]}] "
+ else
+ @out.print ' ' * indent
+ end
+ @line_started = true
+
+ # if start_line is true, move to the next line.
+ elsif options[:start_line]
if @line_started
@out.puts ''
@line_started = false
end
- @stream = options[:stream]
end
# Split the output by line and indent each
@@ -139,7 +151,11 @@ class Chef
@out.puts ''
@line_started = false
elsif !printed_anything
- @out.puts ' ' * indent
+ if options[:name]
+ @out.puts ' ' * (indent + 3 + options[:name].size)
+ else
+ @out.puts ' ' * indent
+ end
end
end
end
@@ -158,7 +174,11 @@ class Chef
def print_line(line, options)
# Start the line with indent if it is not started
if !@line_started
- @out.print ' ' * indent
+ if options[:name]
+ @out.print ' ' * (indent + 3 + options[:name].size)
+ else
+ @out.print ' ' * indent
+ end
@line_started = true
end
# Note that the next line will need to be started