Merge pull request #26 from Simonhancrew/master

[ENH] code refine + fix compile warning
This commit is contained in:
no_one
2023-09-09 20:12:44 +08:00
committed by GitHub
12 changed files with 24 additions and 25 deletions

4
.gitignore vendored
View File

@@ -17,3 +17,7 @@ build/
*.pro
*.user
*bug
# compdb files
.cache/
compile_commands.json

View File

@@ -7,6 +7,7 @@
#define COMMON_BUFFER_BUFFER_INTERFACE
#include "include/cppnet_buffer.h"
#include <memory>
namespace cppnet {

View File

@@ -211,4 +211,4 @@ Log* BaseLogger::NewLog() {
return item;
}
}
} // namespace cppnet

View File

@@ -131,4 +131,4 @@ void FileLogger::CheckExpireFiles() {
}
}
}
} // namespace cppnet

View File

@@ -15,8 +15,6 @@
namespace cppnet {
static const uint8_t __file_logger_time_buf_size = sizeof("xxxx-xx-xx:xx");
enum FileLoggerSpiltUnit {
FLSU_DAY = 1,
FLSU_HOUR = 2,
@@ -54,6 +52,9 @@ private:
void CheckExpireFiles();
private:
enum : uint8_t {
__file_logger_time_buf_size = sizeof("xxxx-xx-xx:xx")
};
std::string _file_name;
std::fstream _stream;
@@ -68,6 +69,6 @@ private:
std::queue<std::string> _history_file_names;
};
}
} // namespace cppnet
#endif
#endif

View File

@@ -65,4 +65,4 @@ LogStreamParam SingletonLogger::GetStreamParam(LogLevel level, const char* file,
return _logger->GetStreamParam(level, file, line);
}
}
} // namespace cppnet

View File

@@ -72,6 +72,6 @@ private:
std::shared_ptr<BaseLogger> _logger;
};
}
} // namespace cppnet
#endif

View File

@@ -128,4 +128,4 @@ LogStream& LogStream::operator<<(char v) {
return *this;
}
}
} // namespace cppnet

View File

@@ -14,7 +14,8 @@
namespace cppnet {
struct Log;
typedef std::pair<std::shared_ptr<Log>, std::function<void(std::shared_ptr<Log>)>> LogStreamParam;
using LogStreamParam =
std::pair<std::shared_ptr<Log>, std::function<void(std::shared_ptr<Log>)>>;
class LogStream {
public:
@@ -47,6 +48,6 @@ private:
std::function<void(std::shared_ptr<Log>)> _call_back;
};
}
} // namespace cppnet
#endif
#endif

View File

@@ -36,6 +36,6 @@ protected:
std::shared_ptr<Logger> _logger;
};
}
} // namespace cppnet
#endif

View File

@@ -8,14 +8,6 @@
namespace cppnet {
StdoutLogger::StdoutLogger() {
}
StdoutLogger::~StdoutLogger() {
}
void StdoutLogger::Debug(std::shared_ptr<Log>& log) {
{
std::unique_lock<std::mutex> lock(_mutex);
@@ -56,4 +48,4 @@ void StdoutLogger::Fatal(std::shared_ptr<Log>& log) {
Logger::Fatal(log);
}
}
} // namespace cppnet

View File

@@ -15,8 +15,8 @@ class StdoutLogger:
public Logger {
public:
StdoutLogger();
~StdoutLogger();
StdoutLogger() = default;
~StdoutLogger() = default;
void Debug(std::shared_ptr<Log>& log);
void Info(std::shared_ptr<Log>& log);
@@ -28,6 +28,6 @@ private:
std::mutex _mutex;
};
}
} // namespace cppnet
#endif