From 8a9fa7c6f995f0e7175982a3200cc28af1ad14ab Mon Sep 17 00:00:00 2001 From: Mike Karlesky Date: Tue, 7 May 2024 15:57:52 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=80=20Resolved=20merge=20conflict?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ported streaminator change for an array argument (in place of usual string) into new and improved loginator. --- lib/ceedling/loginator.rb | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/ceedling/loginator.rb b/lib/ceedling/loginator.rb index d871cf3d..d4062903 100644 --- a/lib/ceedling/loginator.rb +++ b/lib/ceedling/loginator.rb @@ -63,38 +63,44 @@ def set_logfile( log_filepath ) # - Any problematic console characters in a message are replaced with # simpler variants - def log(string, verbosity=Verbosity::NORMAL, label=LogLabels::AUTO, stream=nil) + def log(message, verbosity=Verbosity::NORMAL, label=LogLabels::AUTO, stream=nil) + # Flatten if needed + message = message.flatten.join("\n") if (message.class == Array) + # Call out() with string contatenated with "\n" (unless it aready ends with a newline) - string += "\n" unless string.end_with?( "\n" ) - out( string, verbosity, label, stream ) + message += "\n" unless message.end_with?( "\n" ) + out( message, verbosity, label, stream ) end - def out(string, verbosity=Verbosity::NORMAL, label=LogLabels::AUTO, stream=nil) + def out(message, verbosity=Verbosity::NORMAL, label=LogLabels::AUTO, stream=nil) # Choose appropriate console stream stream = get_stream( verbosity, stream ) + # Flatten if needed + message = message.flatten.join("\n") if (message.class == Array) + # Write to log as though Verbosity::DEBUG (no filtering at all) but without fun characters if @project_logging - file_str = string.dup() # Copy for safe inline modifications + file_msg = message.dup() # Copy for safe inline modifications # Add labels - file_str = format( file_str, verbosity, label, false ) + file_msg = format( file_msg, verbosity, label, false ) # Note: In practice, file-based logging only works with trailing newlines (i.e. `log()` calls) # `out()` calls will be a little ugly in the log file, but these are typically only # used for console logging anyhow. - logfile( sanitize( file_str, false ), extract_stream_name( stream ) ) + logfile( sanitize( file_msg, false ), extract_stream_name( stream ) ) end # Only output to console when message reaches current verbosity level return if !(@verbosinator.should_output?( verbosity )) # Add labels and fun characters - console_str = format( string, verbosity, label, @decorators ) + console_msg = format( message, verbosity, label, @decorators ) # Write to output stream after optionally removing any problematic characters - stream.print( sanitize( console_str, @decorators ) ) + stream.print( sanitize( console_msg, @decorators ) ) end