# # # patch "cmd_netsync.cc" # from [17199b154899d9bfb5c99f02f1c9e6c5d8b1c9e5] # to [00533ab6d6184cdd63d1bd02a74845dc014483bc] # # patch "options_list.hh" # from [44bb545b06f4a7d22e4a5440283b7ac329903137] # to [5050754e775a96d2266a0ade5ac30779e8d14df6] # # patch "ui.cc" # from [31589a9e86d23d92cb4f87b310c6eb920d026db6] # to [995c1af41aea6bf28881b09ee52ab978cf1ccf68] # # patch "ui.hh" # from [13c682946de40aa1900a0b756c86062f95078147] # to [78751360383983100d16c23a04791d9842fff9d9] # ============================================================ --- cmd_netsync.cc 17199b154899d9bfb5c99f02f1c9e6c5d8b1c9e5 +++ cmd_netsync.cc 00533ab6d6184cdd63d1bd02a74845dc014483bc @@ -474,7 +474,8 @@ CMD_NO_WORKSPACE(serve, "serve", "", CMD N_("Serves the database to connecting clients"), "", options::opts::bind | options::opts::pidfile | - options::opts::bind_stdio | options::opts::no_transport_auth ) + options::opts::bind_stdio | options::opts::no_transport_auth | + options::opts::syslog) { if (!args.empty()) throw usage(execid); ============================================================ --- options_list.hh 44bb545b06f4a7d22e4a5440283b7ac329903137 +++ options_list.hh 5050754e775a96d2266a0ade5ac30779e8d14df6 @@ -298,6 +298,15 @@ OPT(last, "last", long, -1, } #endif +OPT(syslog, "syslog", bool, false, + gettext_noop("send log messages to syslog as LOCAL7/{info,warn,err}")) +#ifdef option_bodies +{ + syslog = true; + ui.use_syslog(); +} +#endif + OPTION(globals, log, true, "log", gettext_noop("file to write the log to")) #ifdef option_bodies { ============================================================ --- ui.cc 31589a9e86d23d92cb4f87b310c6eb920d026db6 +++ ui.cc 995c1af41aea6bf28881b09ee52ab978cf1ccf68 @@ -34,6 +34,8 @@ #include "current_exception.hh" +#include + using std::clog; using std::cout; using std::endl; @@ -430,11 +432,12 @@ void tick_write_dot::clear_line() // global, and we don't want global constructors/destructors doing // any real work. see monotone.cc for how this is handled. -user_interface::user_interface() : prog_name("?"), imp(0) {} +user_interface::user_interface() : prog_name("?"), imp(0), syslog(false) {} void user_interface::initialize() { imp = new user_interface::impl; + syslog = false; cout.exceptions(ios_base::badbit); #ifdef SYNC_WITH_STDIO_WORKS @@ -457,6 +460,12 @@ void user_interface::deinitialize() delete imp; } +void user_interface::use_syslog() +{ + openlog(prog_name.c_str(), LOG_PID|LOG_NDELAY, LOG_LOCAL7); + syslog = true; +} + void user_interface::finish_ticking() { ============================================================ --- ui.hh 13c682946de40aa1900a0b756c86062f95078147 +++ ui.hh 78751360383983100d16c23a04791d9842fff9d9 @@ -63,6 +63,7 @@ public: void set_tick_write_nothing(); void ensure_clean_line(); void redirect_log_to(system_path const & filename); + void use_syslog(); std::string output_prefix(); std::string prog_name; @@ -73,6 +74,7 @@ private: struct impl; impl * imp; + bool syslog; friend struct ticker; friend struct tick_write_count;