Make this a default implementation of Logger rather than a special case in Log
This commit is contained in:
@@ -28,27 +28,4 @@ namespace RubberBand
|
||||
|
||||
int Log::m_defaultDebugLevel = 0;
|
||||
|
||||
Log
|
||||
Log::makeCoutLog()
|
||||
{
|
||||
return Log(
|
||||
[](const char *message) {
|
||||
std::cout << "RubberBand: " << message << "\n";
|
||||
},
|
||||
[](const char *message, double arg0) {
|
||||
auto prec = std::cout.precision();
|
||||
std::cout.precision(10);
|
||||
std::cout << "RubberBand: " << message << ": " << arg0 << "\n";
|
||||
std::cout.precision(prec);
|
||||
},
|
||||
[](const char *message, double arg0, double arg1) {
|
||||
auto prec = std::cout.precision();
|
||||
std::cout.precision(10);
|
||||
std::cout << "RubberBand: " << message
|
||||
<< ": (" << arg0 << ", " << arg1 << ")" << "\n";
|
||||
std::cout.precision(prec);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,19 +39,10 @@ public:
|
||||
m_log2(_log2),
|
||||
m_debugLevel(m_defaultDebugLevel) { }
|
||||
|
||||
Log(const Log &other) :
|
||||
m_log0(other.m_log0),
|
||||
m_log1(other.m_log1),
|
||||
m_log2(other.m_log2),
|
||||
m_debugLevel(other.m_debugLevel) { }
|
||||
|
||||
Log &operator=(const Log &other) {
|
||||
m_log0 = other.m_log0;
|
||||
m_log1 = other.m_log1;
|
||||
m_log2 = other.m_log2;
|
||||
m_debugLevel = other.m_debugLevel;
|
||||
return *this;
|
||||
}
|
||||
Log(const Log &other) =default;
|
||||
Log(Log &&other) =default;
|
||||
Log &operator=(const Log &other) =default;
|
||||
Log &operator=(Log &&other) =default;
|
||||
|
||||
void setDebugLevel(int level) { m_debugLevel = level; }
|
||||
int getDebugLevel() const { return m_debugLevel; }
|
||||
@@ -68,8 +59,6 @@ public:
|
||||
if (level <= m_debugLevel) m_log2(message, arg0, arg1);
|
||||
}
|
||||
|
||||
static Log makeCoutLog();
|
||||
|
||||
private:
|
||||
std::function<void(const char *)> m_log0;
|
||||
std::function<void(const char *, double)> m_log1;
|
||||
|
||||
Reference in New Issue
Block a user