# # # patch "app_state.cc" # from [6be9949e433ff6166fd030b34d8eb2d3e18c10b6] # to [92100dc2fc2d02d7c4f1f092a7b3ce2171f6f1cc] # # patch "app_state.hh" # from [f02f3114daf8b81c4a46a5741b1994cc95ebc692] # to [fd92f360dbac7d9acee0ed381012a5e3cdb78f5a] # # patch "cmd_netsync.cc" # from [17199b154899d9bfb5c99f02f1c9e6c5d8b1c9e5] # to [7251a3cc99056a4ebd53fab2d2b3f97080207bcd] # # patch "options_list.hh" # from [44bb545b06f4a7d22e4a5440283b7ac329903137] # to [a739f07377ff6f96d07b8e99e8ac6d3f8c493536] # ============================================================ --- app_state.cc 6be9949e433ff6166fd030b34d8eb2d3e18c10b6 +++ app_state.cc 92100dc2fc2d02d7c4f1f092a7b3ce2171f6f1cc @@ -38,12 +38,26 @@ app_state::app_state() db.set_app(this); lua.set_app(this); keys.set_key_dir(opts.conf_dir / "keys"); + + //this is optional, but good form. we'll default to DAEMON facility + //with INFO level. we'll also ask syslog to push our pid into the + //log message as well for good measure (if running multiple mtn serve's + //this might be handy) + //FIXME: change LOG_USER to LOG_DAEMON is we are running under the serve + //command. + openlog((const char *) ui.prog_name.c_str(), LOG_PID, LOG_USER); } app_state::~app_state() { } +void +app_state::sys_log(std::string const & log_message, int priority) +{ + //not much to do here, syslog is pretty simple (dumb?) + syslog(priority, "%s", log_message.c_str()); +} void app_state::allow_workspace() ============================================================ --- app_state.hh f02f3114daf8b81c4a46a5741b1994cc95ebc692 +++ app_state.hh fd92f360dbac7d9acee0ed381012a5e3cdb78f5a @@ -13,6 +13,8 @@ class lua_hooks; class app_state; class lua_hooks; +#include + #include #include "vector.hh" @@ -74,6 +76,8 @@ public: void require_workspace(std::string const & explanation = ""); void create_workspace(system_path const & dir); + void sys_log(std::string const & log_message, int priority = LOG_INFO); + // Set the branch name. If you only invoke set_branch, the branch // name is not sticky (and won't be written to the workspace and // reused by subsequent monotone invocations). Commands which ============================================================ --- cmd_netsync.cc 17199b154899d9bfb5c99f02f1c9e6c5d8b1c9e5 +++ cmd_netsync.cc 7251a3cc99056a4ebd53fab2d2b3f97080207bcd @@ -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::use_syslog | options::opts::bind_stdio | + options::opts::no_transport_auth ) { if (!args.empty()) throw usage(execid); ============================================================ --- options_list.hh 44bb545b06f4a7d22e4a5440283b7ac329903137 +++ options_list.hh a739f07377ff6f96d07b8e99e8ac6d3f8c493536 @@ -195,6 +195,14 @@ OPT(dryrun, "dry-run", bool, false, } #endif +OPT(use_syslog, "use-syslog", bool, false, + gettext_noop("use the syslog facility to perform logging in addition to standard monotone logging")) +#ifdef option_bodies +{ + use_syslog = true; +} +#endif + OPTION(globals, dump, true, "dump", gettext_noop("file to dump debugging log to, on failure")) #ifdef option_bodies