Commit a500df07 authored by Phil Willoughby's avatar Phil Willoughby Committed by Facebook Github Bot

Use std::cerr for folly/Singleton.cpp error printing

Summary:
Create a local std::ios_base::Init instance to ensure that it is valid, then
use std::cerr.

Reviewed By: yfeldblum, nbronson

Differential Revision: D4139681

fbshipit-source-id: 03377dd417710e320a6b53298d507fd0168592f6
parent 0416e1ea
......@@ -19,10 +19,9 @@
#include <atomic>
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <iostream>
#include <string>
#include <folly/FileUtil.h>
#include <folly/ScopeGuard.h>
namespace folly {
......@@ -31,13 +30,12 @@ namespace detail {
[[noreturn]] void singletonWarnDoubleRegistrationAndAbort(
const TypeDescriptor& type) {
// Not using LOG(FATAL) or std::cerr because they may not be initialized yet.
std::ostringstream o;
o << "Double registration of singletons of the same "
<< "underlying type; check for multiple definitions "
<< "of type folly::Singleton<" << type.name() << ">" << std::endl;
auto s = o.str();
writeFull(STDERR_FILENO, s.data(), s.size());
// Ensure the availability of std::cerr
std::ios_base::Init ioInit;
std::cerr << "Double registration of singletons of the same "
"underlying type; check for multiple definitions "
"of type folly::Singleton<"
<< type.name() << ">\n";
std::abort();
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment