Re: Color highlighting of arbitrary "tail -F'ed" text ?
2008/9/8 Maxim Veksler <[EMAIL PROTECTED]>: > On Fri, Sep 5, 2008 at 9:42 AM, Tzafrir Cohen <[EMAIL PROTECTED]> wrote: >> >> On Fri, Sep 05, 2008 at 09:24:34AM +1000, Amos Shapira wrote: >> >> > Another thing - to page the coloured results through less, use "less >> > -R" (useful to page through bloody puppet's coloured screen log). >> >> And to follow-up to the original poster: press 'F' in less to make it >> behave as 'tail -f' > > > That's a useful feature I will always be using from now on. BTW - If you want to script/alias/automate this, you can pass "+F" to less on its command line so you don't have to manually press "F" inside it. (that's true for any interactive less command, see "man less" and consider also "+G") Cheers, --Amos = To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: Color highlighting of arbitrary "tail -F'ed" text ?
2008/9/8 Maxim Veksler <[EMAIL PROTECTED]>: > On Fri, Sep 5, 2008 at 2:24 AM, Amos Shapira <[EMAIL PROTECTED]> wrote: >> >> 2008/9/5 Tzafrir Cohen <[EMAIL PROTECTED]>: >> > You want to mark 'FINDME' but also find every line? >> > >> > grep --color '^\|FINDME' >> > >> > Or: >> > >> > egrep --color '^|FINDME' >> >> Nice one! I should have though of that. > > Nice indeed. It does match everything but fails to highlight. At least on > EL5 using Konsole. 1. Have you tried this only with "| less -r" by any chance? Maybe since grep's output goes to a pipe and not to the terminal it decides to ignore --color. That's the behavior I see on my Ubunutu. Try "--color=always" when you pipe egrep's output, it helped in on my desktop. 2. Could it be that something is masking your GREP_COLORS envariable (see the --color section in your egrep's manual) --Amos = To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: Color highlighting of arbitrary "tail -F'ed" text ?
On Fri, Sep 5, 2008 at 9:42 AM, Tzafrir Cohen <[EMAIL PROTECTED]> wrote: > > On Fri, Sep 05, 2008 at 09:24:34AM +1000, Amos Shapira wrote: > > > Another thing - to page the coloured results through less, use "less > > -R" (useful to page through bloody puppet's coloured screen log). > > And to follow-up to the original poster: press 'F' in less to make it > behave as 'tail -f' That's a useful feature I will always be using from now on. Though still prefer the Term::ANSIColor; solution that Shlomi implemented above because it allows me to to be as flexible as I want to be. Thanks everyone for the help. > > -- > Tzafrir Cohen | [EMAIL PROTECTED] | VIM is > http://tzafrir.org.il || a Mutt's > [EMAIL PROTECTED] || best > ICQ# 16849754 || friend > -- Cheers, Maxim Veksler "Free as in Freedom" - Do u GNU ? = To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: Color highlighting of arbitrary "tail -F'ed" text ?
On Fri, Sep 5, 2008 at 2:24 AM, Amos Shapira <[EMAIL PROTECTED]> wrote: > 2008/9/5 Tzafrir Cohen <[EMAIL PROTECTED]>: > > You want to mark 'FINDME' but also find every line? > > > > grep --color '^\|FINDME' > > > > Or: > > > > egrep --color '^|FINDME' > > Nice one! I should have though of that. Nice indeed. It does match everything but fails to highlight. At least on EL5 using Konsole. > (Into my bag of tools). > > Another thing - to page the coloured results through less, use "less > -R" (useful to page through bloody puppet's coloured screen log). > > Cheers, > > --Amos > > = > To unsubscribe, send mail to [EMAIL PROTECTED] with > the word "unsubscribe" in the message body, e.g., run the command > echo unsubscribe | mail [EMAIL PROTECTED] > > -- Cheers, Maxim Veksler "Free as in Freedom" - Do u GNU ?
Re: Color highlighting of arbitrary "tail -F'ed" text ?
On Fri, Sep 05, 2008 at 09:24:34AM +1000, Amos Shapira wrote: > Another thing - to page the coloured results through less, use "less > -R" (useful to page through bloody puppet's coloured screen log). And to follow-up to the original poster: press 'F' in less to make it behave as 'tail -f' -- Tzafrir Cohen | [EMAIL PROTECTED] | VIM is http://tzafrir.org.il || a Mutt's [EMAIL PROTECTED] || best ICQ# 16849754 || friend = To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: Color highlighting of arbitrary "tail -F'ed" text ?
2008/9/5 Tzafrir Cohen <[EMAIL PROTECTED]>: > You want to mark 'FINDME' but also find every line? > > grep --color '^\|FINDME' > > Or: > > egrep --color '^|FINDME' Nice one! I should have though of that. (Into my bag of tools). Another thing - to page the coloured results through less, use "less -R" (useful to page through bloody puppet's coloured screen log). Cheers, --Amos = To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: Color highlighting of arbitrary "tail -F'ed" text ?
On Thu, Sep 04, 2008 at 02:31:02PM +0300, Maxim Veksler wrote: > Hi Amos, > > On Thu, Sep 4, 2008 at 2:05 PM, Amos Shapira <[EMAIL PROTECTED]> wrote: > > 2008/9/4 Maxim Veksler <[EMAIL PROTECTED]>: > >> Hi, > >> > >> Someone has a good recommendation for a log syntax highlighter ? > >> > >> I have my application logs where I need to quickly highlight some text, in > >> that case "name=" the output is verbose as I'm running in TRACE. > > > > "grep --color --name={1}" > > > > That would actually be great and is exactly the kind of solution I'm > searching for. The only problem with the grep --color apporoach is > that It would only show me the lines that contain the search term. I > want to see the whole scrolling log and highlight what interested me. You want to mark 'FINDME' but also find every line? grep --color '^\|FINDME' Or: egrep --color '^|FINDME' -- Tzafrir Cohen | [EMAIL PROTECTED] | VIM is http://tzafrir.org.il || a Mutt's [EMAIL PROTECTED] || best ICQ# 16849754 || friend = To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: Color highlighting of arbitrary "tail -F'ed" text ?
On Thursday 04 September 2008, Maxim Veksler wrote: > On Thu, Sep 4, 2008 at 4:17 PM, Shlomi Fish <[EMAIL PROTECTED]> wrote: > > Here's a Proof-of-Concept script I wrote to implement this: > > [snipped] > > I mainly write in Python / Java but the above work from Shlomi is just > great !This is exactly what I've been after, quick dirty and works. > > Thanks a-lot !! > You're welcome. > Shlomi and Amos -- You are the man's ;) Thanks. > > > // OT Note: I must admit that to some one who is accustomed to logic... the > above code is completely unreadable. Could someone please explain where in > the above code the ANSI module / method / operator / what ever they do in > Perl... is called to the actually coloring that was read from stdin? Yes. The key line is: <<< $l =~ s/($re)/colored($1, $c)/eg; >>> $re is a variable containing a regular expression. s/($re)/EXPR()/eg matches all occurences of $re (while capturing it as $1) and replaces them with EXPR(). The expression in our case is: <<< colored($1, $c) >>> It and returns a string that represents $1 coloured using the colour $c. As you should note, I assign $re and $c previously here: <<< my $re = $pat->{pat}; my $c = $pat->{color}; >>> Regards, Shlomi Fish - Shlomi Fish http://www.shlomifish.org/ Rethinking CPAN - http://xrl.us/bjn7p Shlomi, so what are you working on? Working on a new wiki about unit testing fortunes in freecell? -- Ran Eilam = To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: Color highlighting of arbitrary "tail -F'ed" text ?
On Thu, Sep 4, 2008 at 4:17 PM, Shlomi Fish <[EMAIL PROTECTED]> wrote: > On Thursday 04 September 2008, Amos Shapira wrote: > > 2008/9/4 Amos Shapira <[EMAIL PROTECTED]>: > > > 2008/9/4 Maxim Veksler <[EMAIL PROTECTED]>: > > >> That would actually be great and is exactly the kind of solution I'm > > >> searching for. The only problem with the grep --color apporoach is > > >> that It would only show me the lines that contain the search term. I > > >> want to see the whole scrolling log and highlight what interested me. > > > > Also, a quick CPAN search turned up > > http://search.cpan.org/~rra/ANSIColor-1.12/ANSIColor.pm > > If you are a Perl programmer, I'd reckon a 15 minute work will get you > > what you want (but I don't have them right now to do this for you, > > sorry). > > Here's a Proof-of-Concept script I wrote to implement this: > > > #!/usr/bin/perl > > # Written by Shlomi Fish - http://www.shlomifish.org/ - 2008 > # Licensed under the MIT/X11 License. > # > # Example: > # perl color-patterns.pl --pat hello=red --pat '(?i:maxim)'=blue > > use strict; > use warnings; > > use Getopt::Long; > use Term::ANSIColor; > > my %patterns; > GetOptions("pat=s" => \%patterns); > > my @p; > while (my ($k, $v) = each (%patterns)) > { >push @p, { pat => qr{$k}, color => $v }; > } > > while (my $l = <>) > { >foreach my $pat (@p) >{ >my $re = $pat->{pat}; >my $c = $pat->{color}; >$l =~ s/($re)/colored($1, $c)/eg; >} >print $l; > } > > > Regards, > >Shlomi Fish > > - > Shlomi Fish http://www.shlomifish.org/ > Why I Love Perl - http://xrl.us/bjn88 > > Shlomi, so what are you working on? Working on a new wiki about unit > testing > fortunes in freecell? -- Ran Eilam > > I mainly write in Python / Java but the above work from Shlomi is just great !This is exactly what I've been after, quick dirty and works. Thanks a-lot !! Shlomi and Amos -- You are the man's ;) // OT Note: I must admit that to some one who is accustomed to logic... the above code is completely unreadable. Could someone please explain where in the above code the ANSI module / method / operator / what ever they do in Perl... is called to the actually coloring that was read from stdin? -- Cheers, Maxim Veksler "Free as in Freedom" - Do u GNU ?
Re: Color highlighting of arbitrary "tail -F'ed" text ?
On Thursday 04 September 2008, Amos Shapira wrote: > 2008/9/4 Amos Shapira <[EMAIL PROTECTED]>: > > 2008/9/4 Maxim Veksler <[EMAIL PROTECTED]>: > >> That would actually be great and is exactly the kind of solution I'm > >> searching for. The only problem with the grep --color apporoach is > >> that It would only show me the lines that contain the search term. I > >> want to see the whole scrolling log and highlight what interested me. > > Also, a quick CPAN search turned up > http://search.cpan.org/~rra/ANSIColor-1.12/ANSIColor.pm > If you are a Perl programmer, I'd reckon a 15 minute work will get you > what you want (but I don't have them right now to do this for you, > sorry). Here's a Proof-of-Concept script I wrote to implement this: #!/usr/bin/perl # Written by Shlomi Fish - http://www.shlomifish.org/ - 2008 # Licensed under the MIT/X11 License. # # Example: # perl color-patterns.pl --pat hello=red --pat '(?i:maxim)'=blue use strict; use warnings; use Getopt::Long; use Term::ANSIColor; my %patterns; GetOptions("pat=s" => \%patterns); my @p; while (my ($k, $v) = each (%patterns)) { push @p, { pat => qr{$k}, color => $v }; } while (my $l = <>) { foreach my $pat (@p) { my $re = $pat->{pat}; my $c = $pat->{color}; $l =~ s/($re)/colored($1, $c)/eg; } print $l; } Regards, Shlomi Fish - Shlomi Fish http://www.shlomifish.org/ Why I Love Perl - http://xrl.us/bjn88 Shlomi, so what are you working on? Working on a new wiki about unit testing fortunes in freecell? -- Ran Eilam = To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: Color highlighting of arbitrary "tail -F'ed" text ?
2008/9/4 Amos Shapira <[EMAIL PROTECTED]>: > 2008/9/4 Maxim Veksler <[EMAIL PROTECTED]>: >> That would actually be great and is exactly the kind of solution I'm >> searching for. The only problem with the grep --color apporoach is >> that It would only show me the lines that contain the search term. I >> want to see the whole scrolling log and highlight what interested me. Also, a quick CPAN search turned up http://search.cpan.org/~rra/ANSIColor-1.12/ANSIColor.pm If you are a Perl programmer, I'd reckon a 15 minute work will get you what you want (but I don't have them right now to do this for you, sorry). Cheers, --Amos = To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: Color highlighting of arbitrary "tail -F'ed" text ?
2008/9/4 Maxim Veksler <[EMAIL PROTECTED]>: > Hi Amos, > > On Thu, Sep 4, 2008 at 2:05 PM, Amos Shapira <[EMAIL PROTECTED]> wrote: >> 2008/9/4 Maxim Veksler <[EMAIL PROTECTED]>: >>> Hi, >>> >>> Someone has a good recommendation for a log syntax highlighter ? >>> >>> I have my application logs where I need to quickly highlight some text, in >>> that case "name=" the output is verbose as I'm running in TRACE. >> >> "grep --color --name={1}" >> > > That would actually be great and is exactly the kind of solution I'm > searching for. The only problem with the grep --color apporoach is > that It would only show me the lines that contain the search term. I > want to see the whole scrolling log and highlight what interested me. > > Thanks ! Uhh, forgot about that part (I use "grep -color" and it was good for my needs) but I DID forward you to "man grep" didn't I? maybe one of the "*-context" options (look for "Context Line Control" in the manual) help you get what you are after. Cheers, --Amos = To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: Color highlighting of arbitrary "tail -F'ed" text ?
Hi Amos, On Thu, Sep 4, 2008 at 2:05 PM, Amos Shapira <[EMAIL PROTECTED]> wrote: > 2008/9/4 Maxim Veksler <[EMAIL PROTECTED]>: >> Hi, >> >> Someone has a good recommendation for a log syntax highlighter ? >> >> I have my application logs where I need to quickly highlight some text, in >> that case "name=" the output is verbose as I'm running in TRACE. > > "grep --color --name={1}" > That would actually be great and is exactly the kind of solution I'm searching for. The only problem with the grep --color apporoach is that It would only show me the lines that contain the search term. I want to see the whole scrolling log and highlight what interested me. Thanks ! > Replace "{1}" by regular expression which matches the part you want to > highlight in addition to the "name=", maybe "[^ ]*" to highlight up to > the next space. > >> Could some one please suggest a suitable tool as I've tried some project but >> the hardly work. > > "man grep" > > Cheers, > > --Amos > -- Cheers, Maxim Veksler "Free as in Freedom" - Do u GNU ? = To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: Color highlighting of arbitrary "tail -F'ed" text ?
Maxim - Following on Moish's first idea you might want to take a look at http://brianin3d.wordpress.com/tag/bash/ (script is at http://brianin3d.googlepages.com/line_lite.sh) for a script that inserts vt100 escape codes based a pattern. Yaacov Moish wrote: Maxim Veksler wrote: Hi, Someone has a good recommendation for a log syntax highlighter ? I have my application logs where I need to quickly highlight some text, in that case "name=" the output is verbose as I'm running in TRACE. Could some one please suggest a suitable tool as I've tried some project but the hardly work. {..} If it's formatted ( or would be since it's your application ): 1. Add relevant syntax for vt100 terminal or the likes and display the output on such a terminal ( dah.. ) 2. Import into a spreadsheet. 3. For large amounts of data, import into a db, postgres or whatever. Moish = To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED] = To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: Color highlighting of arbitrary "tail -F'ed" text ?
Maxim Veksler wrote: On Thu, Sep 4, 2008 at 1:45 PM, Moish <[EMAIL PROTECTED]> wrote: Maxim Veksler wrote: Hi, Someone has a good recommendation for a log syntax highlighter ? I have my application logs where I need to quickly highlight some text, in that case "name=" the output is verbose as I'm running in TRACE. Could some one please suggest a suitable tool as I've tried some project but the hardly work. {..} If it's formatted ( or would be since it's your application ): 1. Add relevant syntax for vt100 terminal or the likes and display the output on such a terminal ( dah.. ) 2. Import into a spreadsheet. 3. For large amounts of data, import into a db, postgres or whatever. Hmmm, well no. I mean more as a tool I would use for debugging during development. Something that would allow me to do : tail -F /var/log/MyApp/DCN.log | SuperSyntaxHighlighter -SearchForWord="^regexOrSomething" -SearchForWordColor="#FF" I need something would allow me to highlight arbitrary terms in the log. Now I'm searching for "Name" tomorrow I might be search for "objectId". I need a "quick and dirty" solution. Thank you ;) {..} Well, you gave the answer. sed 's/SuperSyntaxHighlighter/sed/' :) use also grep/perl/whatever Moish = To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: Color highlighting of arbitrary "tail -F'ed" text ?
On Thu, Sep 04, 2008 at 01:30:39PM +0300, Maxim Veksler wrote: > Hi, > > Someone has a good recommendation for a log syntax highlighter ? Debian has some packages that seem relevant, I never tried any of them: ccze loco lwatch multitail -- Didi = To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: Color highlighting of arbitrary "tail -F'ed" text ?
2008/9/4 Maxim Veksler <[EMAIL PROTECTED]>: > Hi, > > Someone has a good recommendation for a log syntax highlighter ? > > I have my application logs where I need to quickly highlight some text, in > that case "name=" the output is verbose as I'm running in TRACE. "grep --color --name={1}" Replace "{1}" by regular expression which matches the part you want to highlight in addition to the "name=", maybe "[^ ]*" to highlight up to the next space. > Could some one please suggest a suitable tool as I've tried some project but > the hardly work. "man grep" Cheers, --Amos = To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: Color highlighting of arbitrary "tail -F'ed" text ?
On Thu, Sep 4, 2008 at 1:45 PM, Moish <[EMAIL PROTECTED]> wrote: > > Maxim Veksler wrote: >> >> Hi, >> >> Someone has a good recommendation for a log syntax highlighter ? >> >> I have my application logs where I need to quickly highlight some text, in >> that case "name=" the output is verbose as I'm running in TRACE. >> >> >> Could some one please suggest a suitable tool as I've tried some project but >> the hardly work. > > {..} > > > If it's formatted ( or would be since it's your application ): > > 1. Add relevant syntax for vt100 terminal or the likes and display the > output on such a terminal ( dah.. ) > 2. Import into a spreadsheet. > 3. For large amounts of data, import into a db, postgres or whatever. > Hmmm, well no. I mean more as a tool I would use for debugging during development. Something that would allow me to do : tail -F /var/log/MyApp/DCN.log | SuperSyntaxHighlighter -SearchForWord="^regexOrSomething" -SearchForWordColor="#FF" I need something would allow me to highlight arbitrary terms in the log. Now I'm searching for "Name" tomorrow I might be search for "objectId". I need a "quick and dirty" solution. Thank you ;) Thanks for helping guys. > Moish > -- Cheers, Maxim Veksler "Free as in Freedom" - Do u GNU ? = To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: Color highlighting of arbitrary "tail -F'ed" text ?
Maxim Veksler wrote: Hi, Someone has a good recommendation for a log syntax highlighter ? I have my application logs where I need to quickly highlight some text, in that case "name=" the output is verbose as I'm running in TRACE. Could some one please suggest a suitable tool as I've tried some project but the hardly work. {..} If it's formatted ( or would be since it's your application ): 1. Add relevant syntax for vt100 terminal or the likes and display the output on such a terminal ( dah.. ) 2. Import into a spreadsheet. 3. For large amounts of data, import into a db, postgres or whatever. Moish = To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]