[sf-lug] Fwd: stderr and stdout, merged in a single file, in different colors

Kristian Erik Hermansen kristian.hermansen at gmail.com
Sat Sep 27 16:08:35 PDT 2008


---------- Forwarded message ----------
From: Peter Benjamin <pete at peterbenjamin.com>
Date: Sat, 27 Sep 2008 13:10:13 -0700
Subject: Re: stderr and stdout, merged in a single file, in different colors
To: uuasc at uuasc.org

At 10:43 AM 9/27/2008, you wrote:
>Hi, Group,
>
>Has anyone ever heard of a program that you can pipe stdout and stderr
>into and it will write a log file that has the two streams
>interleaved, but displayed in different colors?
>
>One of my java programmers is asking for this. She seems to think it
>is a normal part of the unix toolkit.

As an unix guru I know I would use standard unix power
techniques to achieve this result.  But it's not simple.

The stdin and stdout in order to be synched so to be
interweaved is the hardest part, and the coloring is
the simplest.

Before I tried it with unix tools, I would instead use
the java to wrapper the executable, so to control
stdin and stdout by having them defined as two
separate io streams into the wrapper, and the wrapper
code would color each unbuffered io block it gets,
and hand them off to a separate thread to write
the final log file.  By using standard unix stty
color commands (keystroke combinations) the log
file would be straight ascii (including non display
characters), and a cat command to the shell window
would display the colors.  The keystroke combos can
actually be typed from the qwerty keyboard without
using the ALT key, via a control character.  There
is a man page that documents this usage.  I forget
the page name.  Google for unix color characters
or similar.

Now, the above paragraph has enough details to implement
this, but only if you pay attention to every word.  Leave
one word out, or not understand the implications of a word,
then it will not work.  Like unbuffered, and separate thread.
------------------------------------------------------------------------
--General instructions--  --Administrative requests--
Post to this list,        Send to Majordomo at uuasc.org, no subject needed
 send to uuasc at uuasc.org  Include ONLY the following in the message BODY
Last resort, send to       To unsubscribe: "unsubscribe uuasc"
 owner-uuasc at uuasc.org     Information or help: "info uuasc" or "help"


-- 
Sent from my mobile device

Kristian Erik Hermansen
http://kristian-hermansen.blogspot.com




More information about the sf-lug mailing list