print errno
This commit is contained in:
parent
6ba52c9f45
commit
c5274a56b8
7
Log.cpp
7
Log.cpp
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <chrono> // date/time
|
#include <chrono> // date/time
|
||||||
|
#include <cstring>
|
||||||
#include <fstream> // ofstream (logging to file)
|
#include <fstream> // ofstream (logging to file)
|
||||||
#include <iostream> // std::ostream, std::cout, std::cin
|
#include <iostream> // std::ostream, std::cout, std::cin
|
||||||
#include <memory> // std::unique_ptr
|
#include <memory> // std::unique_ptr
|
||||||
|
@ -284,6 +285,12 @@ void setColoredOutput(bool enabled) {
|
||||||
dynamic_cast<ConsoleOutput&>(*outputs.at(0)).setColoredOutput(enabled); // has to exist
|
dynamic_cast<ConsoleOutput&>(*outputs.at(0)).setColoredOutput(enabled); // has to exist
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const PrintErrno err;
|
||||||
|
|
||||||
|
std::ostream& operator<<(std::ostream& str, const PrintErrno&) {
|
||||||
|
return str << strerror(errno) << " (" << errno << ')';
|
||||||
|
}
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& str, const FileSize& fs) {
|
std::ostream& operator<<(std::ostream& str, const FileSize& fs) {
|
||||||
static const char PREFIX[] {' ', 'K', 'M', 'G', 'T', 'P', 'E'};
|
static const char PREFIX[] {' ', 'K', 'M', 'G', 'T', 'P', 'E'};
|
||||||
static const uint_fast8_t PREFIXCOUNT = 7;
|
static const uint_fast8_t PREFIXCOUNT = 7;
|
||||||
|
|
6
Log.h
6
Log.h
|
@ -127,6 +127,12 @@ private:
|
||||||
friend std::ostream& operator<<(std::ostream& str, const FileSize& fs);
|
friend std::ostream& operator<<(std::ostream& str, const FileSize& fs);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct PrintErrno {};
|
||||||
|
|
||||||
|
extern const PrintErrno err;
|
||||||
|
|
||||||
|
std::ostream& operator<<(std::ostream& str, const PrintErrno&);
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& str, const FileSize& fs);
|
std::ostream& operator<<(std::ostream& str, const FileSize& fs);
|
||||||
|
|
||||||
// copy Level values in Log namespace
|
// copy Level values in Log namespace
|
||||||
|
|
Loading…
Reference in New Issue