dout: don't print version when forcing fg logging.
Fix tests that were assuming us to spew errors about /var/log, which we
no longer do.
Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
#include <errno.h>
#include <fstream>
#include <iostream>
+#include <sstream>
// debug output
std::ostream *_dout = NULL;
#define _STR(x) #x
#define STRINGIFY(x) _STR(x)
-void _dout_open_log(bool print_version)
+std::string ceph_version_to_string(void)
+{
+ std::ostringstream oss;
+ oss << "ceph version " << VERSION << " (commit:"
+ << STRINGIFY(CEPH_GIT_VER) << ")";
+ return oss.str();
+}
+
+void dout_output_ceph_version(void)
+{
+ generic_dout(-1) << ceph_version_to_string() << dendl;
+}
+
+void _dout_open_log()
{
// should hold _dout_lock here
_dout = new std::ostream(_doss);
}
- if (print_version) {
- _doss->sputc(11);
- *_dout << "ceph version " << VERSION << " (commit:"
- << STRINGIFY(CEPH_GIT_VER) << ")" << std::endl;
- }
_dout_need_open = false;
}
DoutLocker _dout_locker;
if (_dout_need_open)
- _dout_open_log(true);
+ _dout_open_log();
assert(_doss);
_doss->handle_stderr_closed();
DoutLocker _dout_locker;
if (_dout_need_open)
- _dout_open_log(true);
+ _dout_open_log();
assert(_doss);
return _doss->create_rank_symlink(n);
#include "include/assert.h"
#include <iosfwd>
+#include <string>
extern std::ostream *_dout;
extern DoutStreambuf <char> *_doss;
extern bool _dout_need_open;
extern pthread_mutex_t _dout_lock;
-extern void _dout_open_log(bool print_version);
+extern std::string ceph_version_to_string(void);
+
+extern void dout_output_ceph_version(void);
+
+extern void _dout_open_log();
extern int dout_handle_daemonize();
static inline void _dout_begin_line(signed int prio) {
if (unlikely(_dout_need_open))
- _dout_open_log(true);
+ _dout_open_log();
// Put priority information into dout
_doss->sputc(prio + 12);
// before initializing dout(). For now, just force a reopen here with the
// configuration we have just read.
DoutLocker _dout_locker;
- _dout_open_log(false);
+ _dout_open_log();
+ }
+
+ if (!force_fg_logging) {
+ dout_output_ceph_version();
}
if (!cf)
$ monmaptool --create mymonmap
monmaptool: monmap file mymonmap
- failed to open log file '/var/log/ceph/': error 21: Is a directory
\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+ [0-9a-f]{8,} can't open mymonmap: error 2: No such file or directory (re)
monmaptool: generated fsid [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12} (re)
monmaptool: writing epoch 1 to mymonmap (0 monitors)
$ monmaptool --create mymonmap
monmaptool: monmap file mymonmap
- failed to open log file '/var/log/ceph/': error 21: Is a directory
\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+ [0-9a-f]{8,} can't open mymonmap: error 2: No such file or directory (re)
monmaptool: generated fsid [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12} (re)
monmaptool: writing epoch 1 to mymonmap (0 monitors)
$ monmaptool --create --add foo 2.3.4.5:6789 mymonmap
monmaptool: monmap file mymonmap
- failed to open log file '/var/log/ceph/': error 21: Is a directory
\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+ [0-9a-f]{8,} can't open mymonmap: error 2: No such file or directory (re)
monmaptool: generated fsid [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12} (re)
monmaptool: writing epoch 1 to mymonmap (1 monitors)
$ monmaptool --create mymonmap
monmaptool: monmap file mymonmap
- failed to open log file '/var/log/ceph/': error 21: Is a directory
\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+ [0-9a-f]{8,} can't open mymonmap: error 2: No such file or directory (re)
monmaptool: generated fsid [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12} (re)
monmaptool: writing epoch 1 to mymonmap (0 monitors)
$ monmaptool --create --add foo 2.3.4.5:6789 mymonmap
monmaptool: monmap file mymonmap
- failed to open log file '/var/log/ceph/': error 21: Is a directory
\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+ [0-9a-f]{8,} can't open mymonmap: error 2: No such file or directory (re)
monmaptool: generated fsid [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12} (re)
monmaptool: writing epoch 1 to mymonmap (1 monitors)
# TODO be user-friendly
$ monmaptool --help
monmaptool: monmap file --help
- failed to open log file '/var/log/ceph/': error 21: Is a directory
\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+ [0-9a-f]{8,} can't open --help: error 2: No such file or directory (re)
monmaptool: couldn't open --help: Is a directory
[255]
$ monmaptool --print nonexistent
monmaptool: monmap file nonexistent
- failed to open log file '/var/log/ceph/': error 21: Is a directory
\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+ [0-9a-f]{8,} can't open nonexistent: error 2: No such file or directory (re)
monmaptool: couldn't open nonexistent: Is a directory
[255]
$ monmaptool --create --add foo 2.3.4.5:6789 mymonmap
monmaptool: monmap file mymonmap
- failed to open log file '/var/log/ceph/': error 21: Is a directory
\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+ [0-9a-f]{8,} can't open mymonmap: error 2: No such file or directory (re)
monmaptool: generated fsid [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12} (re)
monmaptool: writing epoch 1 to mymonmap (1 monitors)
$ monmaptool --create --add foo 2.3.4.5:6789 mymonmap
monmaptool: monmap file mymonmap
- failed to open log file '/var/log/ceph/': error 21: Is a directory
\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+ [0-9a-f]{8,} can't open mymonmap: error 2: No such file or directory (re)
monmaptool: generated fsid [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12} (re)
monmaptool: writing epoch 1 to mymonmap (1 monitors)