]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
logging: default to foreground logging
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Wed, 2 Mar 2011 12:22:20 +0000 (04:22 -0800)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Wed, 2 Mar 2011 14:40:08 +0000 (06:40 -0800)
At global constructor time: default to logging everything to stderr.

During common_init: set appropriate logging defaults based on the type
or program (daemon or other).

Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
src/common/common_init.cc
src/common/common_init.h
src/common/config.cc
src/crushtool.cc
src/monmaptool.cc

index 9bd3cb96e9c4f24ea2eac8786e73e14dcc99c62b..90f55242661d387c221d98273c38cb25821d95c7 100644 (file)
@@ -111,6 +111,12 @@ static void keyring_init(const char *filesearch)
   }
 }
 
+static void set_cv(const char ** key, const char * const val)
+{
+  free((void*)*key);
+  *key = strdup(val);
+}
+
 void common_init(std::vector<const char*>& args, const char *module_type, int flags)
 {
   bool force_fg_logging = false;
@@ -128,7 +134,13 @@ void common_init(std::vector<const char*>& args, const char *module_type, int fl
          << "and is only suitable for **" << TEXT_NORMAL << std::endl;
     cout << TEXT_YELLOW <<  " **          testing and review.  Do not trust it "
          << "with important data.       **" << TEXT_NORMAL << std::endl;
+
+    // some daemon-specific defaults
     g_conf.daemonize = true;
+    g_conf.log_to_stderr = LOG_TO_STDERR_SOME;
+    g_conf.log_to_file = true;
+    set_cv(&g_conf.log_dir, "/var/log/ceph");
+    set_cv(&g_conf.pid_file, "/var/run/ceph/$type.$id.pid");
   }
   else {
     g_conf.pid_file = 0;
index d94b53a9f5d270e83b5b5792528ca3657966307e..913b02394db206fec28086a3c8705ad05dcc51d9 100644 (file)
@@ -13,6 +13,5 @@ enum {
 void common_init(std::vector<const char*>& args,
                 const char *module_type,
                  int flags);
-void set_foreground_logging();
 
 #endif
index 8a17c46fbe2c1ab7434942728770bcfbccf90231..dfec1aef0adc511b26856c87f6190a0b406e0b0a 100644 (file)
@@ -105,16 +105,16 @@ struct config_option config_optionsp[] = {
        OPTION(profiling_logger_subdir, 0, OPT_STR, 0),
        OPTION(profiling_logger_dir, 0, OPT_STR, "/var/log/ceph/stat"),
        OPTION(log_file, 0, OPT_STR, 0),
-       OPTION(log_dir, 0, OPT_STR, "/var/log/ceph"),
+       OPTION(log_dir, 0, OPT_STR, ""),
        OPTION(log_sym_dir, 0, OPT_STR, 0),
        OPTION(log_sym_history, 0, OPT_INT, 10),
-       OPTION(log_to_stderr, 0, OPT_INT, LOG_TO_STDERR_SOME),
+       OPTION(log_to_stderr, 0, OPT_INT, LOG_TO_STDERR_ALL),
        OPTION(log_to_syslog, 0, OPT_BOOL, false),
        OPTION(log_per_instance, 0, OPT_BOOL, false),
-       OPTION(log_to_file, 0, OPT_BOOL, true),
+       OPTION(log_to_file, 0, OPT_BOOL, false),
        OPTION(clog_to_monitors, 0, OPT_BOOL, true),
        OPTION(clog_to_syslog, 0, OPT_BOOL, false),
-       OPTION(pid_file, 0, OPT_STR, "/var/run/ceph/$type.$id.pid"),
+       OPTION(pid_file, 0, OPT_STR, ""),
        OPTION(conf, 'c', OPT_STR, "/etc/ceph/ceph.conf, ~/.ceph/config, ceph.conf"),
        OPTION(chdir, 0, OPT_STR, "/"),
        OPTION(kill_after, 0, OPT_INT, 0),
index 05e4829fd3798d91657a3cc16b51bf12f5b39d5a..fd27eb87b9b08e052f077f8885852baf6fdf6f9d 100644 (file)
@@ -775,8 +775,6 @@ struct layer_t {
 
 int main(int argc, const char **argv)
 {
-  set_foreground_logging();
-
   vector<const char*> args;
   argv_to_vec(argc, argv, args);
 
index 65dceb0dc6209cfc6a1856b6a4aa7bff433ebe56..e88b606bb898bd64b12fcb36def45cd77497333f 100644 (file)
@@ -38,7 +38,6 @@ int main(int argc, const char **argv)
   vector<const char*> args;
   argv_to_vec(argc, argv, args);
   DEFINE_CONF_VARS(usage);
-  set_foreground_logging();
 
   const char *me = argv[0];