monotone-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Monotone-devel] RFC: lua output redirection


From: Thomas Keller
Subject: [Monotone-devel] RFC: lua output redirection
Date: Fri, 07 May 2010 01:50:44 +0200
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; de; rv:1.9.1.9) Gecko/20100317 Lightning/1.0b2pre Thunderbird/3.0.4

Hi all!

I'd like to hear your comments on a small hack which I added to our lua
hooks code: output redirection for print() and io.write().

The rationale behind this is that lua code (be it hooks or even custom
commands), which likes to "talk" to the user, most likely use the above
mentioned built-ins. These however work directly on STDOUT and this
imposes at least three problems:

1) users cannot distinguish lua output from the application's normal output

2) like 1), but even worse for (remote) stdio: for remote_stdio the
problem is that the user does not even see it (while he maybe wants to),
while for normal stdio the output possibly leads to parsing errors

3) monotone's logging facility (--log) won't catch the output either,
which makes it f.e. hard to debug netsync hooks which are executed in
daemon mode (f.e. Debian's start-stop-daemon has no way to redirect the
daemon's output somewhere else, the application has to take care of that
itself or you need to write some simple wrapper script for that)

So the patch basically introduces a new function "message" (naming
proposals welcome...) which calls our print macro with the given text
input while prefixing every line with "lua: ", and secondly overwrites
print() and io.write() at startup to use the new implementation.

Some notes:

1) io.stdout:write() and io.stderr:write() are still available -
partially because I could not find a way to overwrite / disable them
(they're of userdata type...) and partially because I still wanted to
give the not-so-usual lua hacker a chance to really write to stdout or
stderr if he really wants to do so

2) I haven't yet find a way to print something without a newline with
our sanity setup, so io.write() always up with a newline which is
different from the original behaviour, so it should be documented at least.

3) While both, io.write() and print() previously outputted on stdout,
the new output goes exclusively to stderr (otherwise the points 1) and
2) above wouldn't be easily solvable) - so this is surely another thing
which needs to be documented, in case somebody expects his (lua) output
exclusively on stdout.

So what do you think? Is this something we should do or do you think
this is a bad idea?

Thanks,
Thomas.

-- 
GPG-Key 0x160D1092 | address@hidden | http://thomaskeller.biz
Please note that according to the EU law on data retention, information
on every electronic information exchange might be retained for a period
of six months or longer: http://www.vorratsdatenspeicherung.de/?lang=en

Attachment: lua-output-redirect.patch
Description: Text Data

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]