Skip Menu |

This queue is for tickets about the Term-ANSIColor CPAN distribution.

Report information
The Basics
Id: 87755
Status: rejected
Priority: 0/
Queue: Term-ANSIColor

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 #87755] Log::Log4perl::Appender::ScreenColoredLevels no longer issues RESET
Date: Fri, 09 Aug 2013 16:25:35 -0700
To: bug-Term-ANSIColor [...] rt.cpan.org
From: Russ Allbery <rra [...] stanford.edu>
"Michael Hicks via RT" <bug-Term-ANSIColor@rt.cpan.org> writes: Show quoted text
> 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:
Show quoted text
> return GREEN . $message . RESET;
Show quoted text
> with the new way of using the Term::ANSIColor colored function like: > $msg = Term::ANSIColor::colored( $msg, $color );
Show quoted text
> 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.
Show quoted text
> "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."
What does $msg contain after that line? Does it end with the reset sequence? (\e[0m) -- Russ Allbery (rra@stanford.edu) <http://www.eyrie.org/~eagle/>
Subject: Re: [rt.cpan.org #87755] Log::Log4perl::Appender::ScreenColoredLevels no longer issues RESET
Date: Fri, 9 Aug 2013 17:23:54 -0700
To: bug-Term-ANSIColor [...] rt.cpan.org
From: Michael Hicks <nooneofconsequence [...] gmail.com>
I added code to my log4perl installation to print $msg to a file and on inspecting that file with vim It looks to me like each lineends with: ^[[0m The lines start with: ^[[92m OR ^[[92m for different colors per my logging color settings, and In case it is relevant, my $TERM is set to xterm-256color I'm not sure if this is the same thing, but If I use tput to get the reset characters I normally use in my profile for coloring my prompt: red=$(tput setaf 1) green=$(tput setaf 2) blue=$(tput setaf 4) reset=$(tput sgr0) PS1="\[$red\]\u\[$reset\]@\[$green\]\h\[$reset\]:\[$blue\]\w\[$reset\]\$ " and put them in a file like so: reset=$(tput sgr0) && echo $reset | sudo tee -a reset.txt the file contains: ^[(B^[[m according to terminfo that sgr0 code is " exit_attribute_mode turn off all attributes". I'm not sure if this is the same reset that Term-ANSIColor uses. Michael Hicks nooneofconsequence@gmail.com Sometimes being wrong in interesting ways about interesting things is quite good for starting discussions. On Aug 9, 2013, at 4:25 PM, "rra@stanford.edu via RT" <bug-Term-ANSIColor@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=87755 > > > "Michael Hicks via RT" <bug-Term-ANSIColor@rt.cpan.org> writes: >
>> 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."
> > What does $msg contain after that line? Does it end with the reset > sequence? (\e[0m) > > -- > Russ Allbery (rra@stanford.edu) <http://www.eyrie.org/~eagle/> >
Download smime.p7s
application/pkcs7-signature 4k

Message body not shown because it is not plain text.

CC: undisclosed-recipients:;
Subject: Re: [rt.cpan.org #87755] Log::Log4perl::Appender::ScreenColoredLevels no longer issues RESET
Date: Fri, 09 Aug 2013 17:47:18 -0700
To: bug-Term-ANSIColor [...] rt.cpan.org
From: Russ Allbery <rra [...] stanford.edu>
"Michael Hicks via RT" <bug-Term-ANSIColor@rt.cpan.org> writes: Show quoted text
> Queue: Term-ANSIColor > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=87755 >
Show quoted text
> I added code to my log4perl installation to print $msg to a file and on > inspecting that file with vim It looks to me like each lineends with:
Show quoted text
> ^[[0m
Given that, it seems like Term::ANSIColor is correct here. That's the reset sequence that clears all colors. (The 0 is optional.) So it seems like something else is going on here other than that line or the Term::ANSIColor behavior. Maybe some other part of the code isn't using colored correctly? -- Russ Allbery (rra@stanford.edu) <http://www.eyrie.org/~eagle/>
Subject: Re: [rt.cpan.org #87755] Log::Log4perl::Appender::ScreenColoredLevels no longer issues RESET
Date: Fri, 9 Aug 2013 22:55:02 -0700
To: bug-Term-ANSIColor [...] rt.cpan.org
From: Michael Hicks <nooneofconsequence [...] gmail.com>
I dug into this a bit more and hypothesized that it could be my using Data::Dumper with objects in the output colored by Term-ANSIColor inside log4perl that was causing the problem 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"; In the parent program and the problem went away even at the logging level dumping objects. I'll submit this as a documentation addendum to the log4perl folks. Thanks for your time, Michael Hicks nooneofconsequence@gmail.com Sometimes being wrong in interesting ways about interesting things is quite good for starting discussions. On Aug 9, 2013, at 5:47 PM, rra@stanford.edu via RT <bug-Term-ANSIColor@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=87755 > > > "Michael Hicks via RT" <bug-Term-ANSIColor@rt.cpan.org> writes: >
>> Queue: Term-ANSIColor >> Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=87755 >
>
>> I added code to my log4perl installation to print $msg to a file and on >> inspecting that file with vim It looks to me like each lineends with:
>
>> ^[[0m
> > Given that, it seems like Term::ANSIColor is correct here. That's the > reset sequence that clears all colors. (The 0 is optional.) So it seems > like something else is going on here other than that line or the > Term::ANSIColor behavior. Maybe some other part of the code isn't using > colored correctly? > > -- > Russ Allbery (rra@stanford.edu) <http://www.eyrie.org/~eagle/> >
Download smime.p7s
application/pkcs7-signature 4k

Message body not shown because it is not plain text.