seznam / SuperiorMySqlpp

SuperiorMySQL++
GNU Lesser General Public License v3.0
31 stars 20 forks source link

Full logger implementation uses noexcept for methods that can throw exceptions #87

Open AdamStepan opened 6 years ago

AdamStepan commented 6 years ago

Methods look like this:

virtual void log*(std::uint_fast64_t poolId) const noexcept override
{
    SpinGuard guard{lock};
    std::cerr << stringify("Pool [", poolId, "]: *") << std::flush;
}

But operator<< is not noexcept.

MrWarlockX commented 5 years ago

I suggest using printf functions instead of iostreams, since printf function family are noexcept by default.

majcl commented 5 years ago

iostreams doesnt throw exceptions by default

AdamStepan commented 5 years ago

Yes, but you don't have a guarantee that someone didn't enable them via exceptions method. So, these methods are not noexcept (https://en.cppreference.com/w/cpp/io/basic_ostream/operator_ltlt)