From: Colin Patrick McCabe Date: Wed, 29 Dec 2010 19:12:24 +0000 (-0800) Subject: logging: clean up some error handling X-Git-Tag: v0.25~422 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bbd0ce25899f93df77b95384e15554e526c5bd90;p=ceph.git logging: clean up some error handling Signed-off-by: Colin McCabe --- diff --git a/src/common/DoutStreambuf.cc b/src/common/DoutStreambuf.cc index 3d99af823515..f9b9960f82db 100644 --- a/src/common/DoutStreambuf.cc +++ b/src/common/DoutStreambuf.cc @@ -318,7 +318,7 @@ void DoutStreambuf::read_global_config() } if (g_conf.log_to_file) { - if (_read_ofile_config()) { + if (_read_ofile_config() == 0) { flags |= DOUTSB_FLAG_OFILE; } } @@ -351,7 +351,7 @@ int DoutStreambuf::handle_pid_change() int ret = create_symlink(new_opath, isym_path); if (ret) { ostringstream oss; - oss << __func__ << ": failed to (re)create instance symlink"; + oss << __func__ << ": failed to (re)create instance symlink\n"; primitive_log(oss.str()); return ret; } @@ -362,7 +362,7 @@ int DoutStreambuf::handle_pid_change() int ret = create_symlink(new_opath, rsym_path); if (ret) { ostringstream oss; - oss << __func__ << ": failed to (re)create rank symlink"; + oss << __func__ << ": failed to (re)create rank symlink\n"; primitive_log(oss.str()); return ret; } @@ -509,7 +509,7 @@ std::string DoutStreambuf::_get_symlink_dir() const } template -bool DoutStreambuf::_read_ofile_config() +int DoutStreambuf::_read_ofile_config() { int ret; @@ -520,7 +520,7 @@ bool DoutStreambuf::_read_ofile_config() ostringstream oss; oss << __func__ << ": _calculate_opath failed.\n"; primitive_log(oss.str()); - return false; + return 1; } if (empty(g_conf.log_file) && g_conf.log_per_instance) { @@ -534,7 +534,7 @@ bool DoutStreambuf::_read_ofile_config() ret = _rotate_files(isym_path); if (ret) { ostringstream oss; - oss << __func__ << ": failed to rotate instance symlinks"; + oss << __func__ << ": failed to rotate instance symlinks\n"; primitive_log(oss.str()); return ret; } @@ -543,7 +543,7 @@ bool DoutStreambuf::_read_ofile_config() ret = create_symlink(opath, isym_path); if (ret) { ostringstream oss; - oss << __func__ << ": failed to create instance symlink"; + oss << __func__ << ": failed to create instance symlink\n"; primitive_log(oss.str()); return ret; } @@ -558,10 +558,10 @@ bool DoutStreambuf::_read_ofile_config() oss << "failed to open log file '" << opath << "': " << cpp_strerror(err) << "\n"; primitive_log(oss.str()); - return false; + return err; } - return true; + return 0; } template diff --git a/src/common/DoutStreambuf.h b/src/common/DoutStreambuf.h index 5e93aca4124e..f049dc984d8e 100644 --- a/src/common/DoutStreambuf.h +++ b/src/common/DoutStreambuf.h @@ -83,7 +83,7 @@ private: void _clear_output_buffer(); std::string _calculate_opath() const; std::string _get_symlink_dir() const; - bool _read_ofile_config(); + int _read_ofile_config(); int _rotate_files(const std::string &base); // Output buffer