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 @@ ...@@ -19,10 +19,9 @@
#include <atomic> #include <atomic>
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <sstream> #include <iostream>
#include <string> #include <string>
#include <folly/FileUtil.h>
#include <folly/ScopeGuard.h> #include <folly/ScopeGuard.h>
namespace folly { namespace folly {
...@@ -31,13 +30,12 @@ namespace detail { ...@@ -31,13 +30,12 @@ namespace detail {
[[noreturn]] void singletonWarnDoubleRegistrationAndAbort( [[noreturn]] void singletonWarnDoubleRegistrationAndAbort(
const TypeDescriptor& type) { const TypeDescriptor& type) {
// Not using LOG(FATAL) or std::cerr because they may not be initialized yet. // Ensure the availability of std::cerr
std::ostringstream o; std::ios_base::Init ioInit;
o << "Double registration of singletons of the same " std::cerr << "Double registration of singletons of the same "
<< "underlying type; check for multiple definitions " "underlying type; check for multiple definitions "
<< "of type folly::Singleton<" << type.name() << ">" << std::endl; "of type folly::Singleton<"
auto s = o.str(); << type.name() << ">\n";
writeFull(STDERR_FILENO, s.data(), s.size());
std::abort(); 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