refactor: Elevel => LogLevel enum class, use proper names for items in the class
This commit is contained in:
parent
3472ff6ce5
commit
77bdde5434
27 changed files with 100 additions and 96 deletions
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/ELevel.h"
|
#include "base/LogLevel.h"
|
||||||
#include "common/IInterface.h"
|
#include "common/IInterface.h"
|
||||||
|
|
||||||
//! Interface for architecture dependent logging
|
//! Interface for architecture dependent logging
|
||||||
|
|
@ -47,7 +47,7 @@ public:
|
||||||
/*!
|
/*!
|
||||||
Writes the given string to the log with the given level.
|
Writes the given string to the log with the given level.
|
||||||
*/
|
*/
|
||||||
virtual void writeLog(ELevel, const char *) = 0;
|
virtual void writeLog(LogLevel, const char *) = 0;
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -28,24 +28,25 @@ void ArchLogUnix::showLog(bool)
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArchLogUnix::writeLog(ELevel level, const char *msg)
|
void ArchLogUnix::writeLog(LogLevel level, const char *msg)
|
||||||
{
|
{
|
||||||
// convert level
|
// convert level
|
||||||
int priority;
|
int priority;
|
||||||
switch (level) {
|
switch (level) {
|
||||||
case kERROR:
|
using enum LogLevel;
|
||||||
|
case Error:
|
||||||
priority = LOG_ERR;
|
priority = LOG_ERR;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kWARNING:
|
case Warning:
|
||||||
priority = LOG_WARNING;
|
priority = LOG_WARNING;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kNOTE:
|
case Note:
|
||||||
priority = LOG_NOTICE;
|
priority = LOG_NOTICE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kINFO:
|
case Info:
|
||||||
priority = LOG_INFO;
|
priority = LOG_INFO;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,5 +22,5 @@ public:
|
||||||
void openLog(const char *name) override;
|
void openLog(const char *name) override;
|
||||||
void closeLog() override;
|
void closeLog() override;
|
||||||
void showLog(bool) override;
|
void showLog(bool) override;
|
||||||
void writeLog(ELevel, const char *) override;
|
void writeLog(LogLevel, const char *) override;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -38,17 +38,17 @@ void ArchLogWindows::showLog(bool)
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArchLogWindows::writeLog(ELevel level, const char *msg)
|
void ArchLogWindows::writeLog(LogLevel level, const char *msg)
|
||||||
{
|
{
|
||||||
if (m_eventLog != nullptr) {
|
if (m_eventLog != nullptr) {
|
||||||
// convert priority
|
// convert priority
|
||||||
WORD type;
|
WORD type;
|
||||||
switch (level) {
|
switch (level) {
|
||||||
case kERROR:
|
case LogLevel::Error:
|
||||||
type = EVENTLOG_ERROR_TYPE;
|
type = EVENTLOG_ERROR_TYPE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kWARNING:
|
case LogLevel::Warning:
|
||||||
type = EVENTLOG_WARNING_TYPE;
|
type = EVENTLOG_WARNING_TYPE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ public:
|
||||||
void openLog(const char *name) override;
|
void openLog(const char *name) override;
|
||||||
void closeLog() override;
|
void closeLog() override;
|
||||||
void showLog(bool showIfEmpty) override;
|
void showLog(bool showIfEmpty) override;
|
||||||
void writeLog(ELevel, const char *) override;
|
void writeLog(LogLevel, const char *) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HANDLE m_eventLog;
|
HANDLE m_eventLog;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
add_library(base STATIC
|
add_library(base STATIC
|
||||||
ELevel.h
|
|
||||||
Event.cpp
|
Event.cpp
|
||||||
Event.h
|
Event.h
|
||||||
EventQueue.cpp
|
EventQueue.cpp
|
||||||
|
|
@ -24,6 +23,7 @@ add_library(base STATIC
|
||||||
LogOutputters.h
|
LogOutputters.h
|
||||||
Log.cpp
|
Log.cpp
|
||||||
Log.h
|
Log.h
|
||||||
|
LogLevel.h
|
||||||
Path.cpp
|
Path.cpp
|
||||||
Path.h
|
Path.h
|
||||||
PriorityQueue.h
|
PriorityQueue.h
|
||||||
|
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
/*
|
|
||||||
* Deskflow -- mouse and keyboard sharing utility
|
|
||||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
|
||||||
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
|
|
||||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
//! Log levels
|
|
||||||
/*!
|
|
||||||
The logging priority levels in order of highest to lowest priority.
|
|
||||||
*/
|
|
||||||
enum ELevel
|
|
||||||
{
|
|
||||||
kPRINT = -1, //!< For print only (no file or time)
|
|
||||||
kFATAL, //!< For fatal errors
|
|
||||||
kERROR, //!< For serious errors
|
|
||||||
kWARNING, //!< For minor errors and warnings
|
|
||||||
kNOTE, //!< For messages about notable events
|
|
||||||
kINFO, //!< For informational messages
|
|
||||||
kDEBUG, //!< For important debugging messages
|
|
||||||
kDEBUG1, //!< For verbosity +1 debugging messages
|
|
||||||
kDEBUG2, //!< For verbosity +2 debugging messages
|
|
||||||
kDEBUG3, //!< For verbosity +3 debugging messages
|
|
||||||
kDEBUG4, //!< For verbosity +4 debugging messages
|
|
||||||
kDEBUG5 //!< For verbosity +5 debugging messages
|
|
||||||
};
|
|
||||||
|
|
@ -7,8 +7,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/ELevel.h"
|
|
||||||
#include "base/Log.h"
|
#include "base/Log.h"
|
||||||
|
#include "base/LogLevel.h"
|
||||||
#include "common/IInterface.h"
|
#include "common/IInterface.h"
|
||||||
|
|
||||||
//! Outputter interface
|
//! Outputter interface
|
||||||
|
|
@ -53,7 +53,7 @@ public:
|
||||||
message to all outputters in the outputter chain, otherwise
|
message to all outputters in the outputter chain, otherwise
|
||||||
it continues. Most implementations should return true.
|
it continues. Most implementations should return true.
|
||||||
*/
|
*/
|
||||||
virtual bool write(ELevel level, const char *message) = 0;
|
virtual bool write(LogLevel level, const char *message) = 0;
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#include "base/Log.h"
|
#include "base/Log.h"
|
||||||
#include "arch/Arch.h"
|
#include "arch/Arch.h"
|
||||||
|
#include "base/LogLevel.h"
|
||||||
#include "base/LogOutputters.h"
|
#include "base/LogOutputters.h"
|
||||||
#include "common/Constants.h"
|
#include "common/Constants.h"
|
||||||
|
|
||||||
|
|
@ -33,14 +34,14 @@ static const int g_numPriority = 11;
|
||||||
// for visual studio, then NDEBUG will be set (even if your VS solution
|
// for visual studio, then NDEBUG will be set (even if your VS solution
|
||||||
// config is Debug).
|
// config is Debug).
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
static const int g_defaultMaxPriority = kDEBUG;
|
static const LogLevel g_defaultMaxPriority = LogLevel::Debug;
|
||||||
#else
|
#else
|
||||||
static const int g_defaultMaxPriority = kINFO;
|
static const LogLevel g_defaultMaxPriority = LogLevel::Info;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
ELevel getPriority(const char *&fmt)
|
LogLevel getPriority(const char *&fmt)
|
||||||
{
|
{
|
||||||
if (strnlen(fmt, SIZE_MAX) < kPriorityPrefixLength) {
|
if (strnlen(fmt, SIZE_MAX) < kPriorityPrefixLength) {
|
||||||
throw std::invalid_argument("invalid format string, too short");
|
throw std::invalid_argument("invalid format string, too short");
|
||||||
|
|
@ -50,7 +51,7 @@ ELevel getPriority(const char *&fmt)
|
||||||
throw std::invalid_argument("invalid format string, missing priority");
|
throw std::invalid_argument("invalid format string, missing priority");
|
||||||
}
|
}
|
||||||
|
|
||||||
return static_cast<ELevel>(fmt[2] - '0');
|
return static_cast<LogLevel>(fmt[2] - '0');
|
||||||
}
|
}
|
||||||
|
|
||||||
void makeTimeString(std::vector<char> &buffer)
|
void makeTimeString(std::vector<char> &buffer)
|
||||||
|
|
@ -74,7 +75,7 @@ void makeTimeString(std::vector<char> &buffer)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<char> makeMessage(const char *filename, int lineNumber, const char *message, ELevel priority)
|
std::vector<char> makeMessage(const char *filename, int lineNumber, const char *message, LogLevel priority)
|
||||||
{
|
{
|
||||||
|
|
||||||
// base size includes null terminator, colon, space, etc.
|
// base size includes null terminator, colon, space, etc.
|
||||||
|
|
@ -82,12 +83,13 @@ std::vector<char> makeMessage(const char *filename, int lineNumber, const char *
|
||||||
|
|
||||||
const int timeBufferSize = 50;
|
const int timeBufferSize = 50;
|
||||||
const int priorityMaxSize = 10;
|
const int priorityMaxSize = 10;
|
||||||
|
const auto currentPriority = static_cast<int>(priority);
|
||||||
|
|
||||||
std::vector<char> timeBuffer(timeBufferSize);
|
std::vector<char> timeBuffer(timeBufferSize);
|
||||||
makeTimeString(timeBuffer);
|
makeTimeString(timeBuffer);
|
||||||
|
|
||||||
size_t timestampLength = strnlen(timeBuffer.data(), timeBufferSize);
|
size_t timestampLength = strnlen(timeBuffer.data(), timeBufferSize);
|
||||||
size_t priorityLength = strnlen(g_priority[priority], priorityMaxSize);
|
size_t priorityLength = strnlen(g_priority[currentPriority], priorityMaxSize);
|
||||||
size_t messageLength = strnlen(message, SIZE_MAX);
|
size_t messageLength = strnlen(message, SIZE_MAX);
|
||||||
size_t bufferSize = baseSize + timestampLength + priorityLength + messageLength;
|
size_t bufferSize = baseSize + timestampLength + priorityLength + messageLength;
|
||||||
|
|
||||||
|
|
@ -99,13 +101,13 @@ std::vector<char> makeMessage(const char *filename, int lineNumber, const char *
|
||||||
|
|
||||||
std::vector<char> buffer(bufferSize);
|
std::vector<char> buffer(bufferSize);
|
||||||
snprintf(
|
snprintf(
|
||||||
buffer.data(), bufferSize, "[%s] %s: %s\n\t%s:%d", timeBuffer.data(), g_priority[priority], message, filename,
|
buffer.data(), bufferSize, "[%s] %s: %s\n\t%s:%d", timeBuffer.data(), g_priority[currentPriority], message,
|
||||||
lineNumber
|
filename, lineNumber
|
||||||
);
|
);
|
||||||
return buffer;
|
return buffer;
|
||||||
} else {
|
} else {
|
||||||
std::vector<char> buffer(bufferSize);
|
std::vector<char> buffer(bufferSize);
|
||||||
snprintf(buffer.data(), bufferSize, "[%s] %s: %s", timeBuffer.data(), g_priority[priority], message);
|
snprintf(buffer.data(), bufferSize, "[%s] %s: %s", timeBuffer.data(), g_priority[currentPriority], message);
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -159,12 +161,13 @@ const char *Log::getFilterName() const
|
||||||
return getFilterName(getFilter());
|
return getFilterName(getFilter());
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *Log::getFilterName(int level) const
|
const char *Log::getFilterName(LogLevel level) const
|
||||||
{
|
{
|
||||||
if (level < 0) {
|
const auto levelIndex = static_cast<int>(level);
|
||||||
|
if (levelIndex < 0) {
|
||||||
return "Message";
|
return "Message";
|
||||||
}
|
}
|
||||||
return g_priority[level];
|
return g_priority[levelIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Log::print(const char *file, int line, const char *fmt, ...)
|
void Log::print(const char *file, int line, const char *fmt, ...)
|
||||||
|
|
@ -172,7 +175,7 @@ void Log::print(const char *file, int line, const char *fmt, ...)
|
||||||
const int initBufferSize = 1024;
|
const int initBufferSize = 1024;
|
||||||
const int bufferResizeScale = 2;
|
const int bufferResizeScale = 2;
|
||||||
|
|
||||||
ELevel priority = getPriority(fmt);
|
LogLevel priority = getPriority(fmt);
|
||||||
fmt += kPriorityPrefixLength;
|
fmt += kPriorityPrefixLength;
|
||||||
|
|
||||||
if (priority > getFilter()) {
|
if (priority > getFilter()) {
|
||||||
|
|
@ -196,7 +199,7 @@ void Log::print(const char *file, int line, const char *fmt, ...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priority == kPRINT) {
|
if (priority == LogLevel::Print) {
|
||||||
output(priority, buffer.data());
|
output(priority, buffer.data());
|
||||||
} else {
|
} else {
|
||||||
auto message = makeMessage(file, line, buffer.data(), priority);
|
auto message = makeMessage(file, line, buffer.data(), priority);
|
||||||
|
|
@ -240,7 +243,7 @@ bool Log::setFilter(const char *maxPriority)
|
||||||
if (maxPriority != nullptr) {
|
if (maxPriority != nullptr) {
|
||||||
for (int i = 0; i < g_numPriority; ++i) {
|
for (int i = 0; i < g_numPriority; ++i) {
|
||||||
if (strcmp(maxPriority, g_priority[i]) == 0) {
|
if (strcmp(maxPriority, g_priority[i]) == 0) {
|
||||||
setFilter(i);
|
setFilter(static_cast<LogLevel>(i));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -249,21 +252,21 @@ bool Log::setFilter(const char *maxPriority)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Log::setFilter(int maxPriority)
|
void Log::setFilter(LogLevel maxPriority)
|
||||||
{
|
{
|
||||||
std::scoped_lock lock{m_mutex};
|
std::scoped_lock lock{m_mutex};
|
||||||
m_maxPriority = maxPriority;
|
m_maxPriority = maxPriority;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Log::getFilter() const
|
LogLevel Log::getFilter() const
|
||||||
{
|
{
|
||||||
std::scoped_lock lock{m_mutex};
|
std::scoped_lock lock{m_mutex};
|
||||||
return m_maxPriority;
|
return m_maxPriority;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Log::output(ELevel priority, const char *msg)
|
void Log::output(LogLevel priority, const char *msg)
|
||||||
{
|
{
|
||||||
assert(priority >= -1 && priority < g_numPriority);
|
assert(static_cast<int>(priority) >= -1 && static_cast<int>(priority) < g_numPriority);
|
||||||
assert(msg != nullptr);
|
assert(msg != nullptr);
|
||||||
if (!msg)
|
if (!msg)
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ public:
|
||||||
bool setFilter(const char *name);
|
bool setFilter(const char *name);
|
||||||
|
|
||||||
//! Set the minimum priority filter (by ordinal).
|
//! Set the minimum priority filter (by ordinal).
|
||||||
void setFilter(int);
|
void setFilter(LogLevel);
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
//! @name accessors
|
//! @name accessors
|
||||||
|
|
@ -102,28 +102,28 @@ public:
|
||||||
void print(const char *file, int line, const char *format, ...);
|
void print(const char *file, int line, const char *format, ...);
|
||||||
|
|
||||||
//! Get the minimum priority level.
|
//! Get the minimum priority level.
|
||||||
int getFilter() const;
|
LogLevel getFilter() const;
|
||||||
|
|
||||||
//! Get the filter name of the current filter level.
|
//! Get the filter name of the current filter level.
|
||||||
const char *getFilterName() const;
|
const char *getFilterName() const;
|
||||||
|
|
||||||
//! Get the filter name of a specified filter level.
|
//! Get the filter name of a specified filter level.
|
||||||
const char *getFilterName(int level) const;
|
const char *getFilterName(LogLevel level) const;
|
||||||
|
|
||||||
//! Get the singleton instance of the log
|
//! Get the singleton instance of the log
|
||||||
static Log *getInstance();
|
static Log *getInstance();
|
||||||
|
|
||||||
//! Get the console filter level (messages above this are not sent to
|
//! Get the console filter level (messages above this are not sent to
|
||||||
//! console).
|
//! console).
|
||||||
int getConsoleMaxLevel() const
|
LogLevel getConsoleMaxLevel() const
|
||||||
{
|
{
|
||||||
return kDEBUG2;
|
return LogLevel::Debug2;
|
||||||
}
|
}
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void output(ELevel priority, const char *msg);
|
void output(LogLevel priority, const char *msg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using OutputterList = std::list<ILogOutputter *>;
|
using OutputterList = std::list<ILogOutputter *>;
|
||||||
|
|
@ -133,7 +133,7 @@ private:
|
||||||
mutable std::mutex m_mutex;
|
mutable std::mutex m_mutex;
|
||||||
OutputterList m_outputters;
|
OutputterList m_outputters;
|
||||||
OutputterList m_alwaysOutputters;
|
OutputterList m_alwaysOutputters;
|
||||||
int m_maxPriority;
|
LogLevel m_maxPriority;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -145,7 +145,7 @@ LOG((CLOG_XXX "%d and %d are %s", x, y, x == y ? "equal" : "not equal"));
|
||||||
\endcode
|
\endcode
|
||||||
In particular, notice the double open and close parentheses. Also note
|
In particular, notice the double open and close parentheses. Also note
|
||||||
that there is no comma after the \c CLOG_XXX. The \c XXX should be
|
that there is no comma after the \c CLOG_XXX. The \c XXX should be
|
||||||
replaced by one of enumerants in \c Log::ELevel without the leading
|
replaced by one of enumerants in \c Log::LogLevel without the leading
|
||||||
\c k. For example, \c CLOG_INFO. The special \c CLOG_PRINT level will
|
\c k. For example, \c CLOG_INFO. The special \c CLOG_PRINT level will
|
||||||
not be filtered and is never prefixed by the filename and line number.
|
not be filtered and is never prefixed by the filename and line number.
|
||||||
|
|
||||||
|
|
@ -164,7 +164,7 @@ LOGC(x == y, (CLOG_XXX "%d and %d are equal", x, y));
|
||||||
\endcode
|
\endcode
|
||||||
In particular, notice the parentheses around everything after the boolean
|
In particular, notice the parentheses around everything after the boolean
|
||||||
expression. Also note that there is no comma after the \c CLOG_XXX.
|
expression. Also note that there is no comma after the \c CLOG_XXX.
|
||||||
The \c XXX should be replaced by one of enumerants in \c Log::ELevel
|
The \c XXX should be replaced by one of enumerants in \c Log::LogLevel
|
||||||
without the leading \c k. For example, \c CLOG_INFO. The special
|
without the leading \c k. For example, \c CLOG_INFO. The special
|
||||||
\c CLOG_PRINT level will not be filtered and is never prefixed by the
|
\c CLOG_PRINT level will not be filtered and is never prefixed by the
|
||||||
filename and line number.
|
filename and line number.
|
||||||
|
|
|
||||||
28
src/lib/base/LogLevel.h
Normal file
28
src/lib/base/LogLevel.h
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* Deskflow -- mouse and keyboard sharing utility
|
||||||
|
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
||||||
|
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
|
||||||
|
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
//! Log levels
|
||||||
|
/*!
|
||||||
|
The logging priority levels in order of highest to lowest priority.
|
||||||
|
*/
|
||||||
|
enum class LogLevel
|
||||||
|
{
|
||||||
|
Print = -1, //!< For print only (no file or time)
|
||||||
|
Fatal, //!< For fatal errors
|
||||||
|
Error, //!< For serious errors
|
||||||
|
Warning, //!< For minor errors and warnings
|
||||||
|
Note, //!< For messages about notable events
|
||||||
|
Info, //!< For informational messages
|
||||||
|
Debug, //!< For important debugging messages
|
||||||
|
Debug1, //!< For verbosity +1 debugging messages
|
||||||
|
Debug2, //!< For verbosity +2 debugging messages
|
||||||
|
Debug3, //!< For verbosity +3 debugging messages
|
||||||
|
Debug4, //!< For verbosity +4 debugging messages
|
||||||
|
Debug5 //!< For verbosity +5 debugging messages
|
||||||
|
};
|
||||||
|
|
@ -38,7 +38,7 @@ void StopLogOutputter::show(bool)
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StopLogOutputter::write(ELevel, const char *)
|
bool StopLogOutputter::write(LogLevel, const char *)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -62,9 +62,9 @@ void ConsoleLogOutputter::show(bool showIfEmpty)
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConsoleLogOutputter::write(ELevel level, const char *msg)
|
bool ConsoleLogOutputter::write(LogLevel level, const char *msg)
|
||||||
{
|
{
|
||||||
if ((level >= kFATAL) && (level <= kWARNING))
|
if ((level >= LogLevel::Fatal) && (level <= LogLevel::Warning))
|
||||||
std::cerr << msg << std::endl;
|
std::cerr << msg << std::endl;
|
||||||
else
|
else
|
||||||
std::cout << msg << std::endl;
|
std::cout << msg << std::endl;
|
||||||
|
|
@ -96,7 +96,7 @@ void SystemLogOutputter::show(bool showIfEmpty)
|
||||||
ARCH->showLog(showIfEmpty);
|
ARCH->showLog(showIfEmpty);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SystemLogOutputter::write(ELevel level, const char *msg)
|
bool SystemLogOutputter::write(LogLevel level, const char *msg)
|
||||||
{
|
{
|
||||||
ARCH->writeLog(level, msg);
|
ARCH->writeLog(level, msg);
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -143,7 +143,7 @@ void FileLogOutputter::setLogFilename(const char *logFile)
|
||||||
m_fileName = logFile;
|
m_fileName = logFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileLogOutputter::write(ELevel level, const char *message)
|
bool FileLogOutputter::write(LogLevel level, const char *message)
|
||||||
{
|
{
|
||||||
bool moveFile = false;
|
bool moveFile = false;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ public:
|
||||||
void open(const char *title) override;
|
void open(const char *title) override;
|
||||||
void close() override;
|
void close() override;
|
||||||
void show(bool showIfEmpty) override;
|
void show(bool showIfEmpty) override;
|
||||||
bool write(ELevel level, const char *message) override;
|
bool write(LogLevel level, const char *message) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Write log to console
|
//! Write log to console
|
||||||
|
|
@ -46,7 +46,7 @@ public:
|
||||||
void open(const char *title) override;
|
void open(const char *title) override;
|
||||||
void close() override;
|
void close() override;
|
||||||
void show(bool showIfEmpty) override;
|
void show(bool showIfEmpty) override;
|
||||||
bool write(ELevel level, const char *message) override;
|
bool write(LogLevel level, const char *message) override;
|
||||||
void flush() const;
|
void flush() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -66,7 +66,7 @@ public:
|
||||||
void open(const char *title) override;
|
void open(const char *title) override;
|
||||||
void close() override;
|
void close() override;
|
||||||
void show(bool showIfEmpty) override;
|
void show(bool showIfEmpty) override;
|
||||||
bool write(ELevel level, const char *message) override;
|
bool write(LogLevel level, const char *message) override;
|
||||||
|
|
||||||
void setLogFilename(const char *title);
|
void setLogFilename(const char *title);
|
||||||
|
|
||||||
|
|
@ -88,7 +88,7 @@ public:
|
||||||
void open(const char *title) override;
|
void open(const char *title) override;
|
||||||
void close() override;
|
void close() override;
|
||||||
void show(bool showIfEmpty) override;
|
void show(bool showIfEmpty) override;
|
||||||
bool write(ELevel level, const char *message) override;
|
bool write(LogLevel level, const char *message) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Write log to system log only
|
//! Write log to system log only
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ void logRemoteSecureCipherInfo(const SSL *ssl)
|
||||||
|
|
||||||
void SslLogger::logSecureLibInfo()
|
void SslLogger::logSecureLibInfo()
|
||||||
{
|
{
|
||||||
if (CLOG->getFilter() >= kDEBUG) {
|
if (CLOG->getFilter() >= LogLevel::Debug) {
|
||||||
LOG((CLOG_DEBUG "openssl version: %s", SSLeay_version(SSLEAY_VERSION)));
|
LOG((CLOG_DEBUG "openssl version: %s", SSLeay_version(SSLEAY_VERSION)));
|
||||||
LOG((CLOG_DEBUG1 "openssl flags: %s", SSLeay_version(SSLEAY_CFLAGS)));
|
LOG((CLOG_DEBUG1 "openssl flags: %s", SSLeay_version(SSLEAY_CFLAGS)));
|
||||||
LOG((CLOG_DEBUG1 "openssl built on: %s", SSLeay_version(SSLEAY_BUILT_ON)));
|
LOG((CLOG_DEBUG1 "openssl built on: %s", SSLeay_version(SSLEAY_BUILT_ON)));
|
||||||
|
|
@ -76,7 +76,7 @@ void SslLogger::logSecureLibInfo()
|
||||||
|
|
||||||
void SslLogger::logSecureCipherInfo(const SSL *ssl)
|
void SslLogger::logSecureCipherInfo(const SSL *ssl)
|
||||||
{
|
{
|
||||||
if (ssl && CLOG->getFilter() >= kDEBUG1) {
|
if (ssl && CLOG->getFilter() >= LogLevel::Debug1) {
|
||||||
logLocalSecureCipherInfo(ssl);
|
logLocalSecureCipherInfo(ssl);
|
||||||
logRemoteSecureCipherInfo(ssl);
|
logRemoteSecureCipherInfo(ssl);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ void MSWindowsDebugOutputter::show(bool showIfEmpty)
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MSWindowsDebugOutputter::write(ELevel level, const char *msg)
|
bool MSWindowsDebugOutputter::write(LogLevel level, const char *msg)
|
||||||
{
|
{
|
||||||
OutputDebugString((std::string(msg) + "\n").c_str());
|
OutputDebugString((std::string(msg) + "\n").c_str());
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,6 @@ public:
|
||||||
void open(const char *title) override;
|
void open(const char *title) override;
|
||||||
void close() override;
|
void close() override;
|
||||||
void show(bool showIfEmpty) override;
|
void show(bool showIfEmpty) override;
|
||||||
bool write(ELevel level, const char *message) override;
|
bool write(LogLevel level, const char *message) override;
|
||||||
void flush();
|
void flush();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@
|
||||||
|
|
||||||
#include "arch/Arch.h"
|
#include "arch/Arch.h"
|
||||||
#include "arch/win32/XArchWindows.h"
|
#include "arch/win32/XArchWindows.h"
|
||||||
#include "base/ELevel.h"
|
|
||||||
#include "base/Log.h"
|
#include "base/Log.h"
|
||||||
|
#include "base/LogLevel.h"
|
||||||
#include "base/LogOutputters.h"
|
#include "base/LogOutputters.h"
|
||||||
#include "base/TMethodJob.h"
|
#include "base/TMethodJob.h"
|
||||||
#include "common/Constants.h"
|
#include "common/Constants.h"
|
||||||
|
|
@ -363,7 +363,7 @@ void MSWindowsWatchdog::outputLoop(void *)
|
||||||
|
|
||||||
// strip out windows \r chars to prevent extra lines in log file.
|
// strip out windows \r chars to prevent extra lines in log file.
|
||||||
std::string output = trimOutputBuffer(buffer);
|
std::string output = trimOutputBuffer(buffer);
|
||||||
m_fileLogOutputter.write(kPRINT, output.c_str());
|
m_fileLogOutputter.write(LogLevel::Print, output.c_str());
|
||||||
|
|
||||||
#if SYSAPI_WIN32
|
#if SYSAPI_WIN32
|
||||||
if (m_foreground) {
|
if (m_foreground) {
|
||||||
|
|
|
||||||
|
|
@ -990,7 +990,7 @@ bool XWindowsClipboard::sendReply(Reply *reply)
|
||||||
reply->m_replied = true;
|
reply->m_replied = true;
|
||||||
|
|
||||||
// nothing to log
|
// nothing to log
|
||||||
if (CLOG->getFilter() < kDEBUG2) {
|
if (CLOG->getFilter() < LogLevel::Debug2) {
|
||||||
sendNotify(
|
sendNotify(
|
||||||
reply->m_requestor, m_selection, reply->m_target, reply->m_property, static_cast<unsigned int>(reply->m_time)
|
reply->m_requestor, m_selection, reply->m_target, reply->m_property, static_cast<unsigned int>(reply->m_time)
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
void ArchStringTests::initTestCase()
|
void ArchStringTests::initTestCase()
|
||||||
{
|
{
|
||||||
m_arch.init();
|
m_arch.init();
|
||||||
m_log.setFilter(kDEBUG2);
|
m_log.setFilter(LogLevel::Debug2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArchStringTests::convertStringWCToMB_buffer()
|
void ArchStringTests::convertStringWCToMB_buffer()
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
void UnicodeTests::initTestCase()
|
void UnicodeTests::initTestCase()
|
||||||
{
|
{
|
||||||
m_arch.init();
|
m_arch.init();
|
||||||
m_log.setFilter(kDEBUG2);
|
m_log.setFilter(LogLevel::Debug2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnicodeTests::UTF32ToUTF8()
|
void UnicodeTests::UTF32ToUTF8()
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
void ArgParserTests::initTestCase()
|
void ArgParserTests::initTestCase()
|
||||||
{
|
{
|
||||||
m_arch.init();
|
m_arch.init();
|
||||||
m_log.setFilter(kDEBUG2);
|
m_log.setFilter(LogLevel::Debug2);
|
||||||
static deskflow::ArgsBase base;
|
static deskflow::ArgsBase base;
|
||||||
m_parser.setArgsBase(base);
|
m_parser.setArgsBase(base);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
void ClipboardTests::initTestCase()
|
void ClipboardTests::initTestCase()
|
||||||
{
|
{
|
||||||
m_arch.init();
|
m_arch.init();
|
||||||
m_log.setFilter(kDEBUG2);
|
m_log.setFilter(LogLevel::Debug2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClipboardTests::basicFunction()
|
void ClipboardTests::basicFunction()
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ void ConfigTests::initTestCase()
|
||||||
QVERIFY(dir.mkpath("tmp/test"));
|
QVERIFY(dir.mkpath("tmp/test"));
|
||||||
|
|
||||||
m_arch.init();
|
m_arch.init();
|
||||||
m_log.setFilter(kDEBUG2);
|
m_log.setFilter(LogLevel::Debug2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigTests::loadFile()
|
void ConfigTests::loadFile()
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
void LanguageManagerTests::initTestCase()
|
void LanguageManagerTests::initTestCase()
|
||||||
{
|
{
|
||||||
m_arch.init();
|
m_arch.init();
|
||||||
m_log.setFilter(kDEBUG2);
|
m_log.setFilter(LogLevel::Debug2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LanguageManagerTests::remoteLanguages()
|
void LanguageManagerTests::remoteLanguages()
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ int main(int argc, char **argv)
|
||||||
arch.init();
|
arch.init();
|
||||||
|
|
||||||
Log log;
|
Log log;
|
||||||
log.setFilter(kDEBUG4);
|
log.setFilter(LogLevel::Debug4);
|
||||||
|
|
||||||
::testing::GTEST_FLAG(throw_on_failure) = true;
|
::testing::GTEST_FLAG(throw_on_failure) = true;
|
||||||
testing::InitGoogleTest(&argc, argv);
|
testing::InitGoogleTest(&argc, argv);
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
void MSWindowsClipboardTests::initTestCase()
|
void MSWindowsClipboardTests::initTestCase()
|
||||||
{
|
{
|
||||||
m_arch.init();
|
m_arch.init();
|
||||||
m_log.setFilter(kDEBUG2);
|
m_log.setFilter(LogLevel::Debug2);
|
||||||
|
|
||||||
MSWindowsClipboard clipboard(NULL);
|
MSWindowsClipboard clipboard(NULL);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
void OSXKeyStateTests::initTestCase()
|
void OSXKeyStateTests::initTestCase()
|
||||||
{
|
{
|
||||||
m_arch.init();
|
m_arch.init();
|
||||||
m_log.setFilter(kDEBUG2);
|
m_log.setFilter(LogLevel::Debug2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OSXKeyStateTests::mapModifiersFromOSX_OSXMask()
|
void OSXKeyStateTests::mapModifiersFromOSX_OSXMask()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue