MCPcopy Create free account
hub / github.com/apache/brpc / dump_impl

Method dump_impl

src/bvar/variable.cpp:596–620  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

594
595protected:
596 bool dump_impl(const std::string& name, const butil::StringPiece& desc, const std::string& separator) {
597 if (_fp == NULL) {
598 butil::File::Error error;
599 butil::FilePath dir = butil::FilePath(_filename).DirName();
600 if (!butil::CreateDirectoryAndGetError(dir, &error)) {
601 LOG(ERROR) << "Fail to create directory=`" << dir.value()
602 << "', " << error;
603 return false;
604 }
605 _fp = fopen(_filename.c_str(), "w");
606 if (NULL == _fp) {
607 LOG(ERROR) << "Fail to open " << _filename;
608 return false;
609 }
610 }
611 if (fprintf(_fp, "%.*s%.*s %.*s %.*s\r\n",
612 (int)_prefix.size(), _prefix.data(),
613 (int)name.size(), name.data(),
614 (int)separator.size(), separator.data(),
615 (int)desc.size(), desc.data()) < 0) {
616 PLOG(ERROR) << "Fail to write into " << _filename;
617 return false;
618 }
619 return true;
620 }
621private:
622 std::string _filename;
623 FILE* _fp;

Callers

nothing calls this directly

Calls 7

DirNameMethod · 0.80
FilePathClass · 0.50
valueMethod · 0.45
c_strMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected