*/
#include "logging.hh"
+#include <string>
namespace Logging
{
_callback(std::move(entry));
}
+ void Logger::error(int err, const std::string& msg)
+ {
+ logMessage(msg, std::string(std::strerror(err)));
+ }
+
void Logger::error(const std::string& err, const std::string& msg)
{
logMessage(msg, err);
public:
virtual bool enabled();
virtual void info(const std::string& msg);
+ virtual void error(int err, const std::string& msg);
virtual void error(const std::string& err, const std::string& msg);
virtual std::shared_ptr<Logr::Logger> v(size_t level);
// while the err field should be used to attach the actual error that
// triggered this log line, if present.
virtual void error(const std::string& err, const std::string& msg) = 0;
+ virtual void error(int err, const std::string& msg) = 0;
// V returns an Logger value for a specific verbosity level, relative to
// this Logger. In other words, V values are additive. V higher verbosity
std::string temp = dumpZoneFileName + "XXXXXX";
int fd = mkstemp(&temp.at(0));
if (fd < 0) {
- logger->error(strerror(errno), "Unable to create temporary file");
+ logger->error(errno, "Unable to create temporary file");
return false;
}
if (!fp) {
int err = errno;
close(fd);
- logger->error(stringerror(err), "Unable to open file pointer");
+ logger->error(err, "Unable to open file pointer");
return false;
}
fd = -1;
}
if (fflush(fp.get()) != 0) {
- logger->error(stringerror(), "Error while flushing the content of the RPZ");
+ logger->error(errno, "Error while flushing the content of the RPZ");
return false;
}
if (fsync(fileno(fp.get())) != 0) {
- logger->error(stringerror(), "Error while syncing the content of the RPZ");
+ logger->error(errno, "Error while syncing the content of the RPZ");
return false;
}
if (fclose(fp.release()) != 0) {
- logger->error(stringerror(), "Error while writing the content of the RPZ");
+ logger->error(errno, "Error while writing the content of the RPZ");
return false;
}
if (rename(temp.c_str(), dumpZoneFileName.c_str()) != 0) {
logger
->withValues("destination_file", Logging::Loggable(dumpZoneFileName))
- ->error(stringerror(), "Error while moving the content of the RPZ");
+ ->error(errno, "Error while moving the content of the RPZ");
return false;
}