# # # patch "ChangeLog" # from [c1ee9064be33f06d3e4552f554c2f88785d72235] # to [6cbd487c772cb5a8934bc5ab6b063f82f1a21c2e] # # patch "debian/monotone-server.monotone.init" # from [d852cc0f4ba3cc0ef19f67892fe3454139b27747] # to [da4ecbf7dd0f8573c0585b223c5e46345238445d] # # patch "options_list.hh" # from [583180dc9e0734a39d4ef0c7a97a40ef72ec9a66] # to [c6cecd9fe09a6421655dc8dc432ef94169a86e06] # # patch "ui.cc" # from [f1bb749951aa4f9b75298f15d70b28ca98b217fd] # to [a1622de96871c80dafc936cfd844660dc51803b0] # # patch "ui.hh" # from [ea2c11aaa5de4bc00851ee8bb7a9730f509c93fc] # to [3c8a7736cad88d8005a893a0237ac08edc4b86a1] # ============================================================ --- ChangeLog c1ee9064be33f06d3e4552f554c2f88785d72235 +++ ChangeLog 6cbd487c772cb5a8934bc5ab6b063f82f1a21c2e @@ -1,5 +1,16 @@ 2006-12-09 Richard Levitte + * ui.cc, ui.hh (redirect_output_to, redirect_errors_to): New + functions to redirect the rest of the output streams. + * options_list.hh: New option to redirect error messages. This + is particularly useful in environments with no terminal and no + available shell redirection specifications and you still want to + be able to see what kinds of errors occured. + * debian/monotone-server.monotone.init: Tell the server where + it should write error messages. + +2006-12-09 Richard Levitte + * tests/netsync_permissions_wildcards/__driver__.lua: Don't forget to get() read-permissions and write-permissions. Also, netsync.start should use the full blown netsync.lua, ============================================================ --- debian/monotone-server.monotone.init d852cc0f4ba3cc0ef19f67892fe3454139b27747 +++ debian/monotone-server.monotone.init da4ecbf7dd0f8573c0585b223c5e46345238445d @@ -25,6 +25,7 @@ MAINLOG=/var/log/$NAME/$EXECNAME.log PIDFILE=/var/run/$NAME/$EXECNAME.pid SCRIPTNAME=/etc/init.d/$NAME MAINLOG=/var/log/$NAME/$EXECNAME.log +DUMPLOG=/var/log/$NAME/dump.log ERRORLOG=/var/log/$NAME/error.log MTN_HOME=/var/lib/monotone @@ -56,7 +57,7 @@ d_start() { start-stop-daemon --start --quiet --pidfile $PIDFILE --background \ --exec $DAEMON --chuid monotone --chdir $MTN_HOME -- \ --confdir=$MTN_CONFDIR --db=$MTN_DB --norc --pid-file=$PIDFILE \ - --log=$MAINLOG --dump=$ERRORLOG \ + --log=$MAINLOG --errors=$ERRORLOG --dump=$DUMPLOG \ --rcfile=$MTN_CONFDIR/hooks.lua --keydir=$MTN_KEYDIR --quiet \ --bind=$ADDRESS serve } ============================================================ --- options_list.hh 583180dc9e0734a39d4ef0c7a97a40ef72ec9a66 +++ options_list.hh c6cecd9fe09a6421655dc8dc432ef94169a86e06 @@ -325,6 +325,13 @@ OPTION(globals, log, true, "log", gettex } #endif +OPTION(globals, errors, true, "errors", gettext_noop("file to write the error messages to")) +#ifdef option_bodies +{ + ui.redirect_errors_to(system_path(arg)); +} +#endif + OPTSET(messages) OPTVAR(messages, std::vector, message, ) OPTVAR(messages, utf8, msgfile, ) ============================================================ --- ui.cc f1bb749951aa4f9b75298f15d70b28ca98b217fd +++ ui.cc a1622de96871c80dafc936cfd844660dc51803b0 @@ -58,6 +58,7 @@ #define get_current_exception_type() 0 #endif +using std::cerr; using std::clog; using std::cout; using std::endl; @@ -572,6 +573,28 @@ void } void +user_interface::redirect_output_to(system_path const & filename) +{ + static ofstream filestr; + if (filestr.is_open()) + filestr.close(); + filestr.open(filename.as_external().c_str(), ofstream::out | ofstream::app); + E(filestr.is_open(), F("failed to open log file '%s'") % filename); + cout.rdbuf(filestr.rdbuf()); +} + +void +user_interface::redirect_errors_to(system_path const & filename) +{ + static ofstream filestr; + if (filestr.is_open()) + filestr.close(); + filestr.open(filename.as_external().c_str(), ofstream::out | ofstream::app); + E(filestr.is_open(), F("failed to open log file '%s'") % filename); + cerr.rdbuf(filestr.rdbuf()); +} + +void user_interface::redirect_log_to(system_path const & filename) { static ofstream filestr; ============================================================ --- ui.hh ea2c11aaa5de4bc00851ee8bb7a9730f509c93fc +++ ui.hh 3c8a7736cad88d8005a893a0237ac08edc4b86a1 @@ -102,6 +102,8 @@ public: void set_tick_trailer(std::string const & trailer); void set_tick_writer(tick_writer * t_writer); void ensure_clean_line(); + void redirect_output_to(system_path const & filename); + void redirect_errors_to(system_path const & filename); void redirect_log_to(system_path const & filename); std::string output_prefix();