Skip Menu |

This queue is for tickets about the Log-Log4perl CPAN distribution.

Report information
The Basics
Id: 87756
Status: resolved
Priority: 0/
Queue: Log-Log4perl

People
Owner: Nobody in particular
Requestors: nooneofconsequence [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Log::Log4perl::Appender::ScreenColoredLevels no longer issues RESET
Date: Fri, 9 Aug 2013 16:01:55 -0700
To: bug-Log-Log4perl [...] rt.cpan.org, bug-Term-ANSIColor [...] rt.cpan.org
From: Michael Hicks <nooneofconsequence [...] gmail.com>
I think this is possibly due to a bug in Term::ANSIColor but I'm not sure. I've noticed that if I'm using Log::Log4perl::Appender::ScreenColoredLevels as my appended and have normal perl print statements following a log4perl logger invocation, whatever color setting was used for the last log4perl print gets used for my standard print statement as well. I see that in the patch from issue 30899 which replaced the prior way of using Term::ANSIColor qw(:constants) and actually specifying the RESET in the formatting like: return GREEN . $message . RESET; with the new way of using the Term::ANSIColor colored function like: $msg = Term::ANSIColor::colored( $msg, $color ); from the documentation on Term::ANSIColor here: http://search.cpan.org/~rra/Term-ANSIColor-4.02/ANSIColor.pm it seems colored() is supposed to add the reset for you. "As an aid in resetting colors, colored() takes a scalar as the first argument and any number of attribute strings as the second argument and returns the scalar wrapped in escape codes so that the attributes will be set as requested before the string and reset to normal after the string." I am currently working around this problem by importing the constants interface to my script use Term::ANSIColor qw(:constants); and then adding print RESET; between any log4perl lines and plain ol print statements I want to use which restores the behavior I think I'm used to. I'm seeing this on Debian 7 with liblog-log4perl-perl 1.29-1 which has the version string our $VERSION = '1.29'; in the /usr/share/perl5/Log/Log4perl.pm file and Term::ANSIColor; $VERSION = '3.00'; Michael Hicks nooneofconsequence@gmail.com Sometimes being wrong in interesting ways about interesting things is quite good for starting discussions.
Download smime.p7s
application/pkcs7-signature 4k

Message body not shown because it is not plain text.

Subject: Re: [rt.cpan.org #87756] AutoReply: Log::Log4perl::Appender::ScreenColoredLevels no longer issues RESET
Date: Fri, 9 Aug 2013 23:36:43 -0700
To: bug-Log-Log4perl [...] rt.cpan.org
From: Michael Hicks <nooneofconsequence [...] gmail.com>
After conferring with the maintainer of Term-ANSIColor and some more troubleshooting I've come to the conclusion that this is a phenomenon that only occurs for me when using Data::Dumper with logger invocations. It seems that using Data::Dumper-ized objects in the output colored by Term-ANSIColor inside log4perl results in the terminal not handling the escapes correctly due to the objects being strings that have newline chars in them. When I ran my program with log4perl set to a logging level that didn't dump any objects, the phenomenon didn't occur. So I tried setting $Term::ANSIColor::EACHLINE = "\n"; which tells Term::ANCIColor to add the colorizing and resets at each newline boundary in my parent program and the phenomenon ceased even at the logging level which was dumping objects. Similarly, setting $Term::ANSIColor::EACHLINE = "\n"; in ScreenColoredLevels.pm solves the problem for me too. I've attached a patch for this bug.

Message body is not shown because sender requested not to inline it.

I also tested this with and without %n being set in my layout settings and it properly resets both ways. Thanks for the fantastic log4perl! Michael Hicks nooneofconsequence@gmail.com Show quoted text
> ------------------------------------------------------------------------- > I think this is possibly due to a bug in Term::ANSIColor but I'm not sure. > > > I've noticed that if I'm using Log::Log4perl::Appender::ScreenColoredLevels as my appended and have normal perl print statements following a log4perl logger invocation, whatever color setting was used for the last log4perl print gets used for my standard print statement as well. > > > I see that in the patch from issue 30899 which replaced the prior way of using Term::ANSIColor qw(:constants) and actually specifying the RESET in the formatting like: > return GREEN . $message . RESET; > > with the new way of using the Term::ANSIColor colored function like: > $msg = Term::ANSIColor::colored( $msg, $color ); > > from the documentation on Term::ANSIColor here: http://search.cpan.org/~rra/Term-ANSIColor-4.02/ANSIColor.pm > it seems colored() is supposed to add the reset for you. > "As an aid in resetting colors, colored() takes a scalar as the first argument and any number of attribute strings as the second argument and returns the scalar wrapped in escape codes so that the attributes will be set as requested before the string and reset to normal after the string." > > > > I am currently working around this problem by importing the constants interface to my script > use Term::ANSIColor qw(:constants); > > > and then adding > print RESET; > between any log4perl lines and plain ol print statements I want to use which restores the behavior I think I'm used to. > > I'm seeing this on Debian 7 with liblog-log4perl-perl 1.29-1 which has the version string > our $VERSION = '1.29'; > in the /usr/share/perl5/Log/Log4perl.pm file > > and Term::ANSIColor; > $VERSION = '3.00'; > > > Michael Hicks > nooneofconsequence@gmail.com > > > Sometimes being wrong in interesting ways about interesting things is quite good for starting discussions. >
Download smime.p7s
application/pkcs7-signature 4k

Message body not shown because it is not plain text.

On Sat Aug 10 02:36:56 2013, nooneofconsequence@gmail.com wrote: Show quoted text
> It seems that using Data::Dumper-ized objects in the output colored by > Term-ANSIColor inside log4perl results in the terminal not handling > the escapes correctly due to the objects being strings that have > newline chars in them.
Interesting, do you have a snippet of code that reproduces the problem? When I tried to reproduce it with multi-line strings, the coloring worked as expected: #!/usr/local/bin/perl -w use strict; use Log::Log4perl qw(:easy); my $conf = q( log4perl.category= WARN, Screen log4perl.appender.Screen = Log::Log4perl::Appender::ScreenColoredLevels log4perl.appender.Screen.layout = \ Log::Log4perl::Layout::PatternLayout log4perl.appender.Screen.layout.ConversionPattern = %d %m%n ); Log::Log4perl->init( \$conf ); WARN "this is\na multiline\nmessage"; ERROR "blah blah\nfoo foo";
Subject: Re: [rt.cpan.org #87756] Log::Log4perl::Appender::ScreenColoredLevels no longer issues RESET
Date: Thu, 15 Aug 2013 11:15:06 -0700
To: bug-Log-Log4perl [...] rt.cpan.org
From: Michael Hicks <nooneofconsequence [...] gmail.com>
I had the same problem. I played around with creating a toy version that exhibited the problem but couldn't get it to happen. I'll see if I can get something like that hammered out soon to be able to demo it properly. Thanks for the help, Michael Hicks nooneofconsequence@gmail.com Sometimes being wrong in interesting ways about interesting things is quite good for starting discussions. On Aug 12, 2013, at 8:49 PM, Michael_Schilli via RT <bug-Log-Log4perl@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=87756 > > > On Sat Aug 10 02:36:56 2013, nooneofconsequence@gmail.com wrote:
>> It seems that using Data::Dumper-ized objects in the output colored by >> Term-ANSIColor inside log4perl results in the terminal not handling >> the escapes correctly due to the objects being strings that have >> newline chars in them.
> > Interesting, do you have a snippet of code that reproduces the problem? When I tried to reproduce it with multi-line strings, the coloring worked as expected: > > #!/usr/local/bin/perl -w > use strict; > > use Log::Log4perl qw(:easy); > > my $conf = q( > log4perl.category= WARN, Screen > log4perl.appender.Screen = Log::Log4perl::Appender::ScreenColoredLevels > log4perl.appender.Screen.layout = \ > Log::Log4perl::Layout::PatternLayout > log4perl.appender.Screen.layout.ConversionPattern = %d %m%n > ); > > Log::Log4perl->init( \$conf ); > WARN "this is\na multiline\nmessage"; > ERROR "blah blah\nfoo foo"; >
Download smime.p7s
application/pkcs7-signature 4k

Message body not shown because it is not plain text.