#include <boost/tokenizer.hpp>
#include <cerrno>
-#include <cstring>
using namespace FB;
assert(0 != length);
if (munmap(mem, length) != 0)
- tslog::log("munmap(): ", strerror(errno), "\n");
+ tslog::log("munmap(): ", tslog::print_errno(errno), "\n");
mem = static_cast<decltype(mem)>(MAP_FAILED);
length = 0;
assert(-1 != fd);
if (close(fd) != 0)
- tslog::log("close(): ", strerror(errno), "\n");
+ tslog::log("close(): ", tslog::print_errno(errno), "\n");
fd = -1;
}
assert(nullptr == file);
auto err = [filename] (const char *what) {
- tslog::log("Can't ", what, " ", filename, ": ", strerror(errno), "\n");
+ tslog::log("Can't ", what, " ", filename, ": ", tslog::print_errno(errno), "\n");
return false;
};
#include "tslog.hpp"
#include "libdbuspolicy1-private.h"
+#include <cstring>
+
namespace tslog {
int8_t g_verbosity;
}
log(warning, "\n");
LOGW("%s", warning.c_str());
}
+
+namespace tslog {
+ std::ostream &operator<<(std::ostream &stream, const print_errno &p) {
+ char buf[256];
+ return stream << strerror_r(p.err, buf, sizeof(buf));
+ }
+}
#include <stdlib.h>
#include <string>
-typedef std::ostream& (*t_ManFun)(std::ostream&);
-
namespace tslog
{
/** Checks value of environmental variable with given name */
template <typename ...Args>
void log_verbose(const Args &...args) { if (verbose()) log_to_stream(std::cout, args...); }
+
+ struct print_errno {
+ int err;
+ print_errno(int e) : err(e) {}
+ };
+
+ std::ostream &operator<<(std::ostream &stream, const print_errno &p);
}
#endif