From a48926dee55b18b91744282cb8f0fac9246b7f7f Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Sun, 19 Jan 2020 14:19:34 +0100 Subject: [PATCH] Add and use "should_flog" macro Useful to figure out if a flog category is enabled. We only use it in one place, but it seems like the sort of thing that should exist. --- src/flog.h | 3 +++ src/io.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/flog.h b/src/flog.h index 178016af7..5a4acf5a2 100644 --- a/src/flog.h +++ b/src/flog.h @@ -182,3 +182,6 @@ void log_extra_to_flog_file(const wcstring &s); } while (0) #endif + +#define should_flog(wht) \ + (flog_details::category_list_t::g_instance->wht.enabled) diff --git a/src/io.cpp b/src/io.cpp index ed241237b..afdc8ec0a 100644 --- a/src/io.cpp +++ b/src/io.cpp @@ -257,7 +257,7 @@ bool io_chain_t::append_from_specs(const redirection_spec_list_t &specs, const w FLOGF(warning, NOCLOB_ERROR, spec.target.c_str()); } else { FLOGF(warning, FILE_ERROR, spec.target.c_str()); - if (should_debug(1)) wperror(L"open"); + if (should_flog(warning)) wperror(L"open"); } return false; }