From: Vedansh Bhartia Date: Tue, 1 Aug 2023 18:14:06 +0000 (+0530) Subject: rgw: Restore ostream format state after changing it X-Git-Tag: v19.0.0~314^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=366c68451a07a79a07c76656cc277bd0ad2a0be0;p=ceph.git rgw: Restore ostream format state after changing it Signed-off-by: Vedansh Bhartia --- diff --git a/src/rgw/rgw_asio_frontend.cc b/src/rgw/rgw_asio_frontend.cc index 633a2963300f..e373e4b4cf77 100644 --- a/src/rgw/rgw_asio_frontend.cc +++ b/src/rgw/rgw_asio_frontend.cc @@ -167,8 +167,15 @@ struct log_ms_remainder { }; std::ostream& operator<<(std::ostream& out, const log_ms_remainder& m) { using namespace std::chrono; - return out << std::setfill('0') << std::setw(3) + + std::ios oldState(nullptr); + oldState.copyfmt(out); + + out << std::setfill('0') << std::setw(3) << duration_cast(m.t.time_since_epoch()).count() % 1000; + + out.copyfmt(oldState); + return out; } // log time in apache format: day/month/year:hour:minute:second zone diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc index 5868268c5e1b..a83168373ef2 100644 --- a/src/rgw/rgw_common.cc +++ b/src/rgw/rgw_common.cc @@ -286,10 +286,16 @@ req_state::~req_state() { std::ostream& req_state::gen_prefix(std::ostream& out) const { - auto p = out.precision(); - return out << "req " << id << ' ' + std::ios oldState(nullptr); + oldState.copyfmt(out); + + out << "req " << id << ' ' << std::setprecision(3) << std::fixed << time_elapsed() // '0.123s' - << std::setprecision(p) << std::defaultfloat << ' '; + << ' '; + + out.copyfmt(oldState); + return out; + } bool search_err(rgw_http_errors& errs, int err_no, int& http_ret, string& code) diff --git a/src/rgw/rgw_public_access.cc b/src/rgw/rgw_public_access.cc index 6298bb306d87..d388a59a7bb9 100644 --- a/src/rgw/rgw_public_access.cc +++ b/src/rgw/rgw_public_access.cc @@ -22,12 +22,16 @@ void PublicAccessBlockConfiguration::dump_xml(Formatter *f) const { std::ostream& operator<< (std::ostream& os, const PublicAccessBlockConfiguration& access_conf) { + std::ios oldState(nullptr); + oldState.copyfmt(os); + os << std::boolalpha << "BlockPublicAcls: " << access_conf.block_public_acls() << std::endl << "IgnorePublicAcls: " << access_conf.ignore_public_acls() << std::endl << "BlockPublicPolicy" << access_conf.block_public_policy() << std::endl << "RestrictPublicBuckets" << access_conf.restrict_public_buckets() << std::endl; + os.copyfmt(oldState); return os; }