acimpoeru / google-glog

Automatically exported from code.google.com/p/google-glog
Other
0 stars 0 forks source link

Strongly recommended adding color support #48

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
When i debug a program, I always want to see colorful output to prompt me 
what happening. Especially LOG(ERROR) and VLOG.
Surely I can use VLOG like this 
【VLOG(0) << "\033[32;49;1m" << msg.DebugString() << " \033[39;49;0m";】
or
【LOG(ERROR) << "\033[31;49;1m ERROR Occurred" << " \033[39;49;0m";】
But this is not convenient. I think glog can debug some macros to support 
some standard colorful setting. For example:
【LOG(ERROR) << GLOG_RED << "ERROR Occurred";】
or
【VLOG_RED(0) << "ERROR Occurred";】
【VLOG_GREEN(0) << "ERROR Occurred";】
【VLOG_BLUE(0) << "ERROR Occurred";】
【VLOG_BLUE_BLINK(0) << "ERROR Occurred";】
And restore the color setting after each LOG line output automatically.

Original issue reported on code.google.com by owandyw...@gmail.com on 24 May 2010 at 3:49

GoogleCodeExporter commented 8 years ago
This might be a good idea to support colors. However, I'm not sure if it's 
trivial to 
implement this feature portably (we may need to check termcap/terminfo?). This 
will 
take long time for me. Patches are welcomed :)

Original comment by shinichi...@gmail.com on 27 May 2010 at 9:18

GoogleCodeExporter commented 8 years ago
Attached is a patch for part of this issue - it optionally makes FATAL & ERROR 
message red, and WARNING yellow when logging to stderr, -colorstderr is passed 
_and_ the current terminal supports colored output.  It does not color any VLOG 
output.

I should emphasise that in terms of work most of the legwork in this patch is 
taken from the gtest project (and thus license compatible etc).  I'm only 
responsible for plumbing it into glog (I'll let others judge how cleanly :P)

I have tested it against the latest in SVN (Rev 121) on OS X (10.7.x) & Ubuntu 
12.04 - although I don't have access to a Windows box, the code for Windows 
colorisation is taken directly from gtest and so I strongly suspect it will 
work, but I haven't tested it.

Original comment by alexs....@gmail.com on 11 Jan 2013 at 9:37

Attachments:

GoogleCodeExporter commented 8 years ago
Great!

Could you sign our Contributor License Agreement, please? It
seems that we need to ask you to sign this to avoid any troubles. The
process is just submitting an HTML form, and it shouldn't take your
time so much.

http://code.google.com/legal/individual-cla-v1.0.html

Please note that these forms do not transfer copyright: the
contributor retains her ownership in the work. The CLA just grants
Google a "perpetual, non-exclusive, royalty-free, etc..." right to use
the work, sublicense it, and so on.

Original comment by shinichi...@gmail.com on 12 Jan 2013 at 3:36

GoogleCodeExporter commented 8 years ago
CLA signed (electronically) - let me know if there's anything else I need to do.

Original comment by alexs....@gmail.com on 12 Jan 2013 at 1:29

GoogleCodeExporter commented 8 years ago
Done by http://code.google.com/p/google-glog/source/detail?r=123

I modified this patch by

http://code.google.com/p/google-glog/source/detail?r=124

Note that I renamed the name of flag (colorstderr => colorlogtostderr) because 
original name sounds a bit too general.

Original comment by shinichi...@gmail.com on 23 Jan 2013 at 5:32

GoogleCodeExporter commented 8 years ago

Original comment by shinichi...@gmail.com on 23 Jan 2013 at 5:32