From 027d5bfdca196954937c1b038354ca15b5c699b7 Mon Sep 17 00:00:00 2001 From: Colin Patrick McCabe Date: Wed, 8 Dec 2010 12:58:06 -0800 Subject: [PATCH] logger: tweak cmon log output a bit Make the output of cmon on stderr a little bit less verbose. Signed-off-by: Colin McCabe --- src/common/DoutStreambuf.cc | 2 +- src/mon/Monitor.cc | 12 ++++++------ src/mon/MonitorStore.cc | 19 +++++++++++++------ src/msg/SimpleMessenger.cc | 2 +- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/common/DoutStreambuf.cc b/src/common/DoutStreambuf.cc index 9a7c5b23643c8..9fc489002a5b1 100644 --- a/src/common/DoutStreambuf.cc +++ b/src/common/DoutStreambuf.cc @@ -80,7 +80,7 @@ static void primitive_log(const std::string &str) static inline bool prio_is_visible_on_stderr(int prio) { - return prio <= 9; + return prio <= 5; } static inline int dout_prio_to_syslog_prio(int prio) diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index c126d60c5985f..8f9168cd8088f 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -953,12 +953,12 @@ int Monitor::mkfs(bufferlist& osdmapbl) { // create it int err = store->mkfs(); - if (err < 0) { - char buf[80]; - cerr << "error " << err << " " << strerror_r(err, buf, sizeof(buf)) << std::endl; + if (err) { + dout(0) << TEXT_RED << "** ERROR: store->mkfs failed with error code " + << err << ". Aborting." << dendl; exit(1); } - + bufferlist magicbl; magicbl.append(CEPH_MON_ONDISK_MAGIC); magicbl.append("\n"); @@ -966,9 +966,9 @@ int Monitor::mkfs(bufferlist& osdmapbl) store->put_bl_ss(magicbl, "magic", 0); } catch (const MonitorStore::Error &e) { - std::cerr << TEXT_RED << "** ERROR: initializing cmon failed: couldn't " + dout(0) << TEXT_RED << "** ERROR: initializing cmon failed: couldn't " << "initialize the monitor state machine: " - << e.what() << TEXT_NORMAL << std::endl; + << e.what() << TEXT_NORMAL << dendl; exit(1); } diff --git a/src/mon/MonitorStore.cc b/src/mon/MonitorStore.cc index d8e6cf4bce62d..7984432c629c1 100644 --- a/src/mon/MonitorStore.cc +++ b/src/mon/MonitorStore.cc @@ -106,13 +106,20 @@ int MonitorStore::umount() int MonitorStore::mkfs() { - dout(1) << "mkfs" << dendl; - char cmd[1024]; - snprintf(cmd, sizeof(cmd), "test -d %s && /bin/rm -rf %s ; mkdir -p %s", dir.c_str(), dir.c_str(), dir.c_str()); - dout(1) << cmd << dendl; - int r = system(cmd); - return r; + snprintf(cmd, sizeof(cmd), "test -d %s && /bin/rm -rf %s ; mkdir -p %s", + dir.c_str(), dir.c_str(), dir.c_str()); + dout(6) << "MonitorStore::mkfs: running command '" << cmd << "'" << dendl; + int res = system(cmd); + int r = WEXITSTATUS(res); + if (r) { + dout(0) << "FAILED to create monfs at " << dir.c_str() << " for " + << g_conf.id << ": cmd '" << cmd << "'" << dendl; + return r; + } + + dout(0) << "created monfs at " << dir.c_str() << " for " << g_conf.id << dendl; + return 0; } void MonitorStore::sync() diff --git a/src/msg/SimpleMessenger.cc b/src/msg/SimpleMessenger.cc index cdc1d28399b46..b623585447aff 100644 --- a/src/msg/SimpleMessenger.cc +++ b/src/msg/SimpleMessenger.cc @@ -2376,7 +2376,6 @@ int SimpleMessenger::start(bool nodaemon) << " already started that will now die! call messenger.start() sooner." << dendl; } - dout(1) << "messenger.start daemonizing" << dendl; if (1) { daemon(1, 0); @@ -2398,6 +2397,7 @@ int SimpleMessenger::start(bool nodaemon) ::chdir(g_conf.chdir); } dout_handle_daemonize(); + dout(1) << "messenger.start daemonized" << dendl; } // go! -- 2.39.5