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.
This commit is contained in:
Fabian Homborg 2020-01-19 14:19:34 +01:00
parent 349b9e9dee
commit a48926dee5
2 changed files with 4 additions and 1 deletions

View File

@ -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)

View File

@ -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;
}