18 #if defined(ACTS_ENABLE_LOG_FAILURE_THRESHOLD) and \
19 not defined(ACTS_LOG_FAILURE_THRESHOLD)
21 Level& getFailureThresholdMutable() {
22 static Level _level = []() {
25 const char* envvar = std::getenv(
"ACTS_LOG_FAILURE_THRESHOLD");
26 if (envvar ==
nullptr) {
30 if (slevel ==
"VERBOSE") {
32 }
else if (slevel ==
"DEBUG") {
34 }
else if (slevel ==
"INFO") {
36 }
else if (slevel ==
"WARNING") {
38 }
else if (slevel ==
"ERROR") {
40 }
else if (slevel ==
"FATAL") {
43 std::cerr <<
"ACTS_LOG_FAILURE_THRESHOLD environment variable is set to "
45 << slevel << std::endl;
55 return getFailureThresholdMutable();
59 getFailureThresholdMutable() =
level;
65 throw std::logic_error{
66 "Compile-time log failure threshold defined (ACTS_LOG_FAILURE_THRESHOLD "
67 "is set or ACTS_ENABLE_LOG_FAILURE_THRESHOLD is OFF), unable to "
69 "https://acts.readthedocs.io/en/latest/core/"
70 "logging.html#logging-thresholds"};
76 class NeverFilterPolicy final :
public OutputFilterPolicy {
78 ~NeverFilterPolicy()
override =
default;
80 bool doPrint(
const Level& )
const override {
return false; }
84 std::unique_ptr<OutputFilterPolicy> clone(
Level )
const override {
85 return std::make_unique<NeverFilterPolicy>();
89 std::unique_ptr<const Logger> makeDummyLogger() {
90 using namespace Logging;
91 auto output = std::make_unique<DefaultPrintPolicy>(&std::cout);
92 auto print = std::make_unique<NeverFilterPolicy>();
101 std::ostream* log_stream) {
102 using namespace Logging;
103 auto output = std::make_unique<LevelOutputDecorator>(
104 std::make_unique<NamedOutputDecorator>(
105 std::make_unique<TimedOutputDecorator>(
106 std::make_unique<DefaultPrintPolicy>(log_stream)),
108 auto print = std::make_unique<DefaultFilterPolicy>(lvl);
113 static const std::unique_ptr<const Logger>
logger =
114 Logging::makeDummyLogger();