case CODE_ENVIRONMENT_LIBRARY:
conf->set_val_or_die("log_to_stderr", "false");
conf->set_val_or_die("err_to_stderr", "false");
+ conf->set_val_or_die("log_flush_on_exit", "false");
break;
default:
ceph::crypto::init();
cct->start_service_thread();
+ if (cct->_conf->log_flush_on_exit)
+ cct->_log->set_flush_on_exit();
+
// Trigger callbacks on any config observers that were waiting for
// it to become safe to start threads.
cct->_conf->set_val("internal_safe_to_start_threads", "true");
OPTION(num_client, OPT_INT, 1)
OPTION(monmap, OPT_STR, "")
OPTION(mon_host, OPT_STR, "")
-OPTION(daemonize, OPT_BOOL, false)
OPTION(lockdep, OPT_BOOL, false)
OPTION(admin_socket, OPT_STR, "/var/run/ceph/$cluster.name.asok")
+
+OPTION(daemonize, OPT_BOOL, false)
+OPTION(pid_file, OPT_STR, "")
+OPTION(chdir, OPT_STR, "/")
+OPTION(max_open_files, OPT_LONGLONG, 0)
+
OPTION(log_file, OPT_STR, "/var/log/ceph/$cluster.$name.log")
OPTION(log_max_new, OPT_INT, 1000)
OPTION(log_max_recent, OPT_INT, 1000000)
OPTION(err_to_stderr, OPT_BOOL, true)
OPTION(log_to_syslog, OPT_BOOL, false)
OPTION(err_to_syslog, OPT_BOOL, false)
+OPTION(log_flush_on_exit, OPT_BOOL, true)
+
OPTION(clog_to_monitors, OPT_BOOL, true)
OPTION(clog_to_syslog, OPT_BOOL, false)
-OPTION(pid_file, OPT_STR, "")
-OPTION(chdir, OPT_STR, "/")
-OPTION(max_open_files, OPT_LONGLONG, 0)
DEFAULT_SUBSYS(0, 5)
SUBSYS(lockdep, 0, 5)
block_signals(siglist, NULL);
install_standard_sighandlers();
+ if (g_conf->log_flush_on_exit)
+ g_ceph_context->_log->set_flush_on_exit();
+
if (g_lockdep) {
dout(1) << "lockdep is enabled" << dendl;
lockdep_register_ceph_context(cct);
}
Log::Log(SubsystemMap *s)
- : m_indirect_this(new (Log*)(this)), // we will deliberately leak this
+ : m_indirect_this(NULL),
m_subs(s),
m_new(), m_recent(),
m_fd(-1),
{
int ret;
- // Make sure we flush on shutdown. We do this by deliberately
- // leaking an indirect pointer to ourselves (on_exit() can't
- // unregister a callback). This is not racy only becuase we
- // assume that exit() won't race with ~Log().
- on_exit(log_on_exit, m_indirect_this);
-
ret = pthread_spin_init(&m_lock, PTHREAD_PROCESS_SHARED);
assert(ret == 0);
Log::~Log()
{
- *m_indirect_this = NULL;
+ if (m_indirect_this) {
+ *m_indirect_this = NULL;
+ }
assert(!is_started());
if (m_fd >= 0)
///
+void Log::set_flush_on_exit()
+{
+ // Make sure we flush on shutdown. We do this by deliberately
+ // leaking an indirect pointer to ourselves (on_exit() can't
+ // unregister a callback). This is not racy only becuase we
+ // assume that exit() won't race with ~Log().
+ if (m_indirect_this == NULL) {
+ m_indirect_this = new (Log*)(this);
+ on_exit(log_on_exit, m_indirect_this);
+ }
+}
+
void Log::set_max_new(int n)
{
m_max_new = n;
Log(SubsystemMap *s);
virtual ~Log();
+ void set_flush_on_exit();
+
void set_max_new(int n);
void set_max_recent(int n);
void set_log_file(std::string fn);