Hi, I think this has already been asked on the list, but I can''t seem to be able to find it again: currently, active record does some weird thing with its sql logs i.e.: [4;33mSQL (0.000000) [1;37mPRAGMA table_info(map_locations) how do I remove the "[4;35m" thx Jean
replying to myself : I finally found the reference : http://one.textdrive.com/pipermail/rails/2004-November/000557.html The thread doesn''t mention why the color is here in the first place, this still seems weird to me. Jean On Fri, 4 Mar 2005 09:04:00 +0100, Jean Helou <jean.helou-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > I think this has already been asked on the list, but I can''t seem to > be able to find it again: > > currently, active record does some weird thing with its sql logs i.e.: > [4;33mSQL (0.000000) [1;37mPRAGMA table_info(map_locations) > > how do I remove the "[4;35m" > > thx > Jean >
On Friday 04 March 2005 08:22, Jean Helou wrote:> replying to myself : I finally found the reference : > > http://one.textdrive.com/pipermail/rails/2004-November/000557.html > > The thread doesn''t mention why the color is here in the first place, > this still seems weird to me. > > > currently, active record does some weird thing with its sql logs i.e.: > > [4;33mSQL (0.000000) [1;37mPRAGMA table_info(map_locations) > > > > how do I remove the "[4;35m"less -r is the easiest way to view them, as you''re probably aware. If you want to remove them... hmm... I''m sure there''s probably a way to do it with sed (and ruby, of course :), but this little C program is supposed to do it: http://www.cix.co.uk/~mayday/code/filt.c -- Lee.
Actually I went and edited the format_log_entry to remove all notion of formatting for the moment. I am using ROR on windows, and I don''t think installing the whole cygwin environnement is the correct answer to be able to read my logs unpolluted by color escaping. I could implement a custom formatter for log4r to be able to remove the color escaping from the logs as it streams them to stdout, but I don''t think I should have to. Now if I submit a patch that will allow users to enable or disable the color escaping from environment.rb, will it be considered ? Jean On Fri, 4 Mar 2005 09:39:46 +0000, Lee Braiden <jel-OMY0mCUCxqbPG/DoapTOmA@public.gmane.org> wrote:> On Friday 04 March 2005 08:22, Jean Helou wrote: > > replying to myself : I finally found the reference : > > > > http://one.textdrive.com/pipermail/rails/2004-November/000557.html > > > > The thread doesn''t mention why the color is here in the first place, > > this still seems weird to me. > > > > > currently, active record does some weird thing with its sql logs i.e.: > > > [4;33mSQL (0.000000) [1;37mPRAGMA table_info(map_locations) > > > > > > how do I remove the "[4;35m" > > less -r is the easiest way to view them, as you''re probably aware. If you > want to remove them... hmm... I''m sure there''s probably a way to do it with > sed (and ruby, of course :), but this little C program is supposed to do it: > > http://www.cix.co.uk/~mayday/code/filt.c > > -- > Lee. > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Jean Helou wrote:> I could implement a custom formatter for log4r to be able to remove > the color escaping from the logs as it streams them to stdout, but I > don''t think I should have to.I agree you shouldn''t have to. Perhaps a custom formatter would have been the right place to *add* colouring, for those who want it? Justin
* Justin Forder <justin-zSfPWr5aQuznITO/+xaoB7VCufUGDwFn@public.gmane.org> [0317 11:17]:> Jean Helou wrote: > > >I could implement a custom formatter for log4r to be able to remove > >the color escaping from the logs as it streams them to stdout, but I > >don''t think I should have to. > > I agree you shouldn''t have to. Perhaps a custom formatter would have been > the right place to *add* colouring, for those who want it?Turning that around: Most of us like it. So why do we have to throw a knob to turn it off? -- ''Interesting. No, wait, the other thing - Tedious.'' -- Bender Rasputin :: Jack of All Trades - Master of Nuns
Dick Davies wrote:>* Justin Forder <justin-zSfPWr5aQuznITO/+xaoB7VCufUGDwFn@public.gmane.org> [0317 11:17]: > > >>Jean Helou wrote: >> >> >> >>>I could implement a custom formatter for log4r to be able to remove >>>the color escaping from the logs as it streams them to stdout, but I >>>don''t think I should have to. >>> >>> >>I agree you shouldn''t have to. Perhaps a custom formatter would have been >>the right place to *add* colouring, for those who want it? >> >> > >Turning that around: > > Most of us like it. So why do we have to throw a knob to turn it off? > >I didn''t mean to imply that the custom formatter wouldn''t be used in the out-of-the-box configuration. Just that adding fancy formatting seems appropriately done in a formatter. (I haven''t checked to see how feasible it is.)
Jean Helou wrote:> Actually I went and edited the format_log_entry to remove all notion > of formatting for the moment. > > I am using ROR on windows, and I don''t think installing the whole > cygwin environnement is the correct answer to be able to read my logs > unpolluted by color escaping. > > I could implement a custom formatter for log4r to be able to remove > the color escaping from the logs as it streams them to stdout, but I > don''t think I should have to. > > Now if I submit a patch that will allow users to enable or disable the > color escaping from environment.rb, will it be considered ?Put this at the end of config/environment.rb to turn coloring off. class ActiveRecord::ConnectionAdapters::AbstractAdapter protected def format_log_entry(message, dump = nil) "%s %s" % [message, dump] end end jeremy
While we are on the topic of logs. Is there a chance to get a patch included which sets all of rails logging to level debug for easier disabling on production? On Fri, 04 Mar 2005 07:02:47 -0800, Jeremy Kemper <jeremy-w7CzD/W5Ocjk1uMJSBkQmQ@public.gmane.org> wrote:> Jean Helou wrote: > > Actually I went and edited the format_log_entry to remove all notion > > of formatting for the moment. > > > > I am using ROR on windows, and I don''t think installing the whole > > cygwin environnement is the correct answer to be able to read my logs > > unpolluted by color escaping. > > > > I could implement a custom formatter for log4r to be able to remove > > the color escaping from the logs as it streams them to stdout, but I > > don''t think I should have to. > > > > Now if I submit a patch that will allow users to enable or disable the > > color escaping from environment.rb, will it be considered ? > > Put this at the end of config/environment.rb to turn coloring off. > > class ActiveRecord::ConnectionAdapters::AbstractAdapter > protected > def format_log_entry(message, dump = nil) > "%s %s" % [message, dump] > end > end > > jeremy > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Tobi http://www.snowdevil.ca - Snowboards that don''t suck http://www.hieraki.org - Open source book authoring http://blog.leetsoft.com - Technical weblog
On Fri, 04 Mar 2005 11:17:33 +0000, Justin Forder <justin-zSfPWr5aQuznITO/+xaoB7VCufUGDwFn@public.gmane.org> wrote:> Jean Helou wrote: > > > I could implement a custom formatter for log4r to be able to remove > > the color escaping from the logs as it streams them to stdout, but I > > don''t think I should have to. > > I agree you shouldn''t have to. Perhaps a custom formatter would have been the right place to *add* colouring, for those who want it?I''m not sure why anyone wants formatting in a log file anyway. ANSI escape sequences only make the logs more difficult to use for things other than watching requests come in. How about defining a standard, plain-text log file format, and having a "watchlog" script that colorizes the output (and can be piped to a pager)? Sam
I don''t know what you do with your log files, but the only thing I do is look at them, and I think the colors are great. I hope this starts a trend. -Jeff ----- Original Message ----- From: "Sam Stephenson" <sstephenson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> To: <rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> Sent: Friday, March 04, 2005 12:23 PM Subject: Re: [Rails] Re: active record logs format> On Fri, 04 Mar 2005 11:17:33 +0000, Justin Forder > <justin-zSfPWr5aQuznITO/+xaoB7VCufUGDwFn@public.gmane.org> wrote: >> Jean Helou wrote: >> >> > I could implement a custom formatter for log4r to be able to remove >> > the color escaping from the logs as it streams them to stdout, but I >> > don''t think I should have to. >> >> I agree you shouldn''t have to. Perhaps a custom formatter would have been >> the right place to *add* colouring, for those who want it? > > I''m not sure why anyone wants formatting in a log file anyway. ANSI > escape sequences only make the logs more difficult to use for things > other than watching requests come in. > > How about defining a standard, plain-text log file format, and having > a "watchlog" script that colorizes the output (and can be piped to a > pager)? > > Sam > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
I agree with Jeff: The majority of log use is for debugging, not statistical analysis. For that reason, the default should be "most readable format to most people." If there are customizations that would fit other circumstances, it would make sense to make them more easily customizable than they currently are. (Perhaps some commented code in the default environment.rb?) Duane Johnson (canadaduane) On Fri, 4 Mar 2005 12:34:20 -0700, Jeffrey Moss <jeff-61uStg5MtoFWk0Htik3J/w@public.gmane.org> wrote:> I don''t know what you do with your log files, but the only thing I do is > look at them, and I think the colors are great. I hope this starts a trend. > > -Jeff > > ----- Original Message ----- > From: "Sam Stephenson" <sstephenson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > To: <rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> > Sent: Friday, March 04, 2005 12:23 PM > Subject: Re: [Rails] Re: active record logs format > > > On Fri, 04 Mar 2005 11:17:33 +0000, Justin Forder > > <justin-zSfPWr5aQuznITO/+xaoB7VCufUGDwFn@public.gmane.org> wrote: > >> Jean Helou wrote: > >> > >> > I could implement a custom formatter for log4r to be able to remove > >> > the color escaping from the logs as it streams them to stdout, but I > >> > don''t think I should have to. > >> > >> I agree you shouldn''t have to. Perhaps a custom formatter would have been > >> the right place to *add* colouring, for those who want it? > > > > I''m not sure why anyone wants formatting in a log file anyway. ANSI > > escape sequences only make the logs more difficult to use for things > > other than watching requests come in. > > > > How about defining a standard, plain-text log file format, and having > > a "watchlog" script that colorizes the output (and can be piped to a > > pager)? > > > > Sam > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Well, my intention certainly wasn''t to start a flame war. It''s more a feature request. Have an easy way to disable coloring for users who want their logs uncluttered. I don''t think this is something unreasonable to ask. Unfortunately not everyone has tools to read these escapes. My special thanks to Jeremy, who provided me with the cleanest way to remove the coloring from my logs. I am not yet sure to understand how it can work but it does. I still have quite a bit of ruby to learn I guess. I intend to create a wiki page: howto configure logging sometime during the weekend to document this and a few other things about logging. Jean On Fri, 4 Mar 2005 12:34:20 -0700, Jeffrey Moss <jeff-61uStg5MtoFWk0Htik3J/w@public.gmane.org> wrote:> I don''t know what you do with your log files, but the only thing I do is > look at them, and I think the colors are great. I hope this starts a trend. > > -Jeff > > ----- Original Message ----- > From: "Sam Stephenson" <sstephenson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > To: <rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> > Sent: Friday, March 04, 2005 12:23 PM > Subject: Re: [Rails] Re: active record logs format > > > On Fri, 04 Mar 2005 11:17:33 +0000, Justin Forder > > <justin-zSfPWr5aQuznITO/+xaoB7VCufUGDwFn@public.gmane.org> wrote: > >> Jean Helou wrote: > >> > >> > I could implement a custom formatter for log4r to be able to remove > >> > the color escaping from the logs as it streams them to stdout, but I > >> > don''t think I should have to. > >> > >> I agree you shouldn''t have to. Perhaps a custom formatter would have been > >> the right place to *add* colouring, for those who want it? > > > > I''m not sure why anyone wants formatting in a log file anyway. ANSI > > escape sequences only make the logs more difficult to use for things > > other than watching requests come in. > > > > How about defining a standard, plain-text log file format, and having > > a "watchlog" script that colorizes the output (and can be piped to a > > pager)? > > > > Sam > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
On 04 Mar 2005, at 11:34, Jeffrey Moss wrote:> ----- Original Message ----- From: "Sam Stephenson" > <sstephenson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > To: <rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> > Sent: Friday, March 04, 2005 12:23 PM > Subject: Re: [Rails] Re: active record logs format > > >> On Fri, 04 Mar 2005 11:17:33 +0000, Justin Forder >> <justin-zSfPWr5aQuznITO/+xaoB7VCufUGDwFn@public.gmane.org> wrote: >>> Jean Helou wrote: >>> >>> > I could implement a custom formatter for log4r to be able to remove >>> > the color escaping from the logs as it streams them to stdout, but >>> I >>> > don''t think I should have to. >>> >>> I agree you shouldn''t have to. Perhaps a custom formatter would have >>> been the right place to *add* colouring, for those who want it? >> >> I''m not sure why anyone wants formatting in a log file anyway. ANSI >> escape sequences only make the logs more difficult to use for things >> other than watching requests come in. >> >> How about defining a standard, plain-text log file format, and having >> a "watchlog" script that colorizes the output (and can be piped to a >> pager)? > > I don''t know what you do with your log files, but the only thing I do > is look at them, and I think the colors are great. I hope this starts > a trend.(Don''t top post.) $ ls -l /var/log/prod* -rw-r----- 1 root wheel 139991762 Mar 4 17:33 /var/log/production.log -rw-r----- 1 root wheel 11518652 Mar 4 00:00 /var/log/production.log.0.bz2 -rw-r----- 1 root wheel 16266319 Mar 3 00:00 /var/log/production.log.1.bz2 -rw-r----- 1 root wheel 15984815 Mar 2 00:00 /var/log/production.log.2.bz2 -rw-r----- 1 root wheel 14547130 Mar 1 00:00 /var/log/production.log.3.bz2 -rw-r----- 1 root wheel 13231014 Feb 28 00:00 /var/log/production.log.4.bz2 -rw-r----- 1 root wheel 13791426 Feb 27 00:00 /var/log/production.log.5.bz2 -rw-r----- 1 root wheel 27323696 Feb 26 00:00 /var/log/production.log.6.bz2 -rw-r----- 1 root wheel 27939473 Feb 25 00:00 /var/log/production.log.7.bz2 In other words, I: 1) Pipe them through syslog. 2) Rotate them daily 3) Keep them for 7 days As you can see, 17.5 hours of logs is 134M, or 2K/sec per machine. I don''t know of anybody who reads logs that fast, but after going through syslog the "colors" turn into [4;33mSQL (0.000000) These color sequences make in very difficult to perform any kind of statistical analysis of the log files (and when you''re logging 4K/sec that is very important information), and having to add a color stripper to my syslog logger was quite annoying. PS: I don''t know of anybody who can read logs at 4K/sec, so at this level of traffic, the colors are quite silly, not to mention that they take up 16bytes per line, which is 16 less bytes of output I can fit into a syslog line. PPS: syslog logging lets you see which process did what, rather than having your processes all log on top of each other, making them much, much more useful. -- Eric Hodel - drbrain-48TerJ1FxhPk1uMJSBkQmQ@public.gmane.org - http://segment7.net FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04 _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On 04 Mar 2005, at 13:58, Duane Johnson wrote:> I agree with Jeff: The majority of log use is for debugging, not > statistical analysis.As of this writing there are 11 people in this thread. 7 people found some reason to disable colors 2 people like colors, and don''t want to get rid of them. 2 people talked about some related subject In the referenced thread: 4 of 4 people found some reason to disable colors It seems that the majority of the people here would like some way of removing colors from their logs. (I log to syslog, so I *HAVE* to strip colors) -- Eric Hodel - drbrain-48TerJ1FxhPk1uMJSBkQmQ@public.gmane.org - http://segment7.net FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04 _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
> It seems that the majority of the people here would like some way of > removing colors from their logs.While agreeing that the logs should remain as they are (by default), I didn''t mean to disagree with others in this thread who need clear text logs. I also agree that disabling ANSI in the logs is useful. I would do it myself on a production server for statistical analysis. Duane
Jeffrey Moss wrote:> I don''t know what you do with your log files, but the only thing I do is > look at them, and I think the colors are great. I hope this starts a trend. > > -Jeff >what about sending them to a mailing list to request assistance? victor
Jeremy Kemper wrote:>Put this at the end of config/environment.rb to turn coloring off. > >class ActiveRecord::ConnectionAdapters::AbstractAdapter > protected > def format_log_entry(message, dump = nil) > "%s %s" % [message, dump] > end >end >Jeremy, thanks! For a newcomer like me, this is a great demonstration of the value of being able to add to or amend existing classes in your own code. Justin