syslog(LOG_USER | LOG_NOTICE, "%s", str.c_str());
}
-static inline bool prio_is_visible_on_stderr(int prio)
+static inline bool prio_is_visible_on_stderr(signed int prio)
{
- return prio <= 5;
+ return prio == -1;
}
static inline int dout_prio_to_syslog_prio(int prio)
}
// Loop over all lines in the buffer.
- int prio = 100;
+ signed int prio = 100;
charT* start = obuf;
while (true) {
char* end = strchrnul(start, '\n');
// Decode some control characters
++start;
unsigned char tmp = *((unsigned char*)start);
- prio = tmp - 11;
+ prio = tmp;
+ prio -= 12;
++start;
}
*end = '\n';
if (g_conf.log_to_syslog) {
flags |= DOUTSB_FLAG_SYSLOG;
}
+
if (g_conf.log_to_stdout) {
if (fd_is_open(STDOUT_FILENO)) {
flags |= DOUTSB_FLAG_STDOUT;
}
}
- if (fd_is_open(STDERR_FILENO)) {
- flags |= DOUTSB_FLAG_STDERR;
+
+ if (g_conf.log_to_stderr) {
+ if (fd_is_open(STDERR_FILENO)) {
+ flags |= DOUTSB_FLAG_STDERR;
+ }
}
+
if (g_conf.log_to_file) {
if (_read_ofile_config()) {
flags |= DOUTSB_FLAG_OFILE;
}
}
-template <typename charT, typename traits>
-void DoutStreambuf<charT, traits>::
-set_flags(int flags_)
-{
- assert(_dout_lock.is_locked());
- flags = flags_;
-}
-
template <typename charT, typename traits>
void DoutStreambuf<charT, traits>::
set_prio(int prio)
{
assert(_dout_lock.is_locked());
ostringstream oss;
- oss << "g_conf.log_to_syslog = " << g_conf.log_to_syslog << "\n";
oss << "g_conf.log_to_stdout = " << g_conf.log_to_stdout << "\n";
+ oss << "g_conf.log_to_stderr = " << g_conf.log_to_stderr << "\n";
+ oss << "g_conf.log_to_syslog = " << g_conf.log_to_syslog << "\n";
oss << "g_conf.log_to_file = " << g_conf.log_to_file << "\n";
oss << "g_conf.log_file = '" << cpp_str(g_conf.log_file) << "'\n";
oss << "g_conf.log_dir = '" << cpp_str(g_conf.log_dir) << "'\n";
// Set the flags based on the global configuration
void read_global_config();
- // Set the flags directly (for debug use only)
- void set_flags(int flags_);
-
// Set the priority of the messages being put into the stream
void set_prio(int prio);
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2010 Dreamhost
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation. See file COPYING.
+ *
+ */
+#include "auth/AuthSupported.h"
+#include "auth/KeyRing.h"
#include "config.h"
-#include "tls.h"
-
#include "include/color.h"
-
-#include "auth/KeyRing.h"
-#include "auth/AuthSupported.h"
+#include "tls.h"
void common_set_defaults(bool daemon)
{
g_conf.daemonize = true;
g_conf.logger = true;
- g_conf.log_to_stdout = false;
} else {
g_conf.pid_file = 0;
}
}
}
}
-
extern int dout_create_rank_symlink(int n);
-static inline void _dout_begin_line(int prio) {
+static inline void _dout_begin_line(signed int prio) {
if (unlikely(_dout_need_open))
_dout_open_log();
// Put priority information into dout
_doss->sputc(1);
- _doss->sputc(prio + 11);
+ _doss->sputc(prio + 12);
// Some information that goes in every dout message
*_dout << g_clock.now() << " " << std::hex << pthread_self()
#define dendl std::endl; } } while (0)
+#define derr dout(-1)
extern void hex2str(const char *s, int len, char *buf, int dest_len);
#include "include/types.h"
#include "common/Clock.h"
+#include "common/DoutStreambuf.h"
#include "common/Logger.h"
#include "common/BackTrace.h"
OPTION(log_dir, 0, OPT_STR, "/var/log/ceph"),
OPTION(log_sym_dir, 0, OPT_STR, 0),
OPTION(log_sym_history, 0, OPT_INT, 10),
- OPTION(log_to_stdout, 0, OPT_BOOL, true),
OPTION(log_to_syslog, 0, OPT_BOOL, false),
OPTION(log_per_instance, 0, OPT_BOOL, false),
OPTION(log_to_file, 0, OPT_BOOL, true),
std::vector<const char *> nargs;
bool conf_specified = false;
+ g_conf.log_to_stdout = false;
+ g_conf.log_to_stderr = true;
+
if (!g_conf.id)
g_conf.id = (char *)g_default_id;
if (!g_conf.type)
show_config = true;
} else if (isdaemon && CONF_ARG_EQ("bind", 0)) {
g_conf.public_addr.parse(args[++i]);
- } else if (isdaemon && CONF_ARG_EQ("nodaemon", 'D')) {
+ } else if (CONF_ARG_EQ("nodaemon", 'D')) {
g_conf.daemonize = false;
g_conf.log_to_stdout = true;
- /*
- } else if (isdaemon && CONF_ARG_EQ("daemonize", 'd')) {
- g_conf.daemonize = true;
- g_conf.log_to_stdout = false;
- */
- } else if (isdaemon && CONF_ARG_EQ("foreground", 'f')) {
+ g_conf.log_to_stderr = false;
+ } else if (CONF_ARG_EQ("foreground", 'f')) {
g_conf.daemonize = false;
- //g_conf.log_to_stdout = false;
} else if (isdaemon && (CONF_ARG_EQ("id", 'i') || CONF_ARG_EQ("name", 'n'))) {
CONF_SAFE_SET_ARG_VAL(&g_conf.id, OPT_STR);
} else if (!isdaemon && (CONF_ARG_EQ("id", 'I') || CONF_ARG_EQ("name", 'n'))) {
{
cerr << " -c ceph.conf or --conf=ceph.conf\n";
cerr << " get options from given conf file" << std::endl;
+ cerr << " -D run in foreground.\n";
+ cerr << " -f run in foreground. Show all log messages on stdout.\n";
}
void generic_server_usage()
{
cerr << " --debug_ms N\n";
cerr << " set message debug level (e.g. 1)\n";
- cerr << " -D debug (no fork, log to stdout)\n";
- cerr << " -f foreground (no fork, log to file)\n";
generic_usage();
exit(1);
}
void generic_client_usage()
{
generic_usage();
- cerr << " -d daemonize (detach, fork, log to file)\n";
- cerr << " -f foreground (no fork, log to file)" << std::endl;
exit(1);
}
const char *log_dir;
const char *log_sym_dir;
int log_sym_history;
+
bool log_to_stdout;
+ bool log_to_stderr;
bool log_to_syslog;
bool log_per_instance;
bool log_to_file;