pmt: reformat code, etc.
This commit is contained in:
@@ -82,8 +82,7 @@ public:
|
||||
};
|
||||
|
||||
// A class for function management.
|
||||
template <class _Type>
|
||||
class basic_manager {
|
||||
template <class _Type> class basic_manager {
|
||||
private:
|
||||
std::vector<std::unique_ptr<_Type>> _functions;
|
||||
|
||||
@@ -127,8 +126,7 @@ public:
|
||||
}
|
||||
|
||||
[[nodiscard]] bool handleAll() const {
|
||||
LOGN(PMTF, INFO) << "running caught commands in command-line."
|
||||
<< std::endl;
|
||||
LOGN(PMTF, INFO) << "running caught commands in command-line." << std::endl;
|
||||
for (const auto &func : _functions) {
|
||||
if (func->isUsed()) {
|
||||
LOGN(PMTF, INFO) << func->name()
|
||||
|
||||
@@ -60,17 +60,29 @@ constexpr int YES = 1;
|
||||
constexpr int NO = 0;
|
||||
|
||||
namespace Helper {
|
||||
// Throwable error class
|
||||
class Error final : public std::exception {
|
||||
private:
|
||||
std::string _message;
|
||||
std::ostringstream _oss;
|
||||
|
||||
public:
|
||||
__attribute__((format(printf, 2, 3))) explicit Error(const char *format, ...);
|
||||
|
||||
[[nodiscard]] const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
// Logging
|
||||
class Logger final {
|
||||
private:
|
||||
LogLevels _level;
|
||||
std::ostringstream _oss;
|
||||
const char *_funcname, *_logFile, *_program_name, *_file;
|
||||
const char *_function_name, *_logFile, *_program_name, *_file;
|
||||
int _line;
|
||||
|
||||
public:
|
||||
Logger(LogLevels level, const char *func, const char *file, const char *name,
|
||||
const char *sfile, int line);
|
||||
const char *source_file, int line);
|
||||
|
||||
~Logger();
|
||||
|
||||
@@ -82,17 +94,6 @@ public:
|
||||
Logger &operator<<(std::ostream &(*msg)(std::ostream &));
|
||||
};
|
||||
|
||||
// Throwable error class
|
||||
class Error final : public std::exception {
|
||||
private:
|
||||
std::string _message;
|
||||
|
||||
public:
|
||||
__attribute__((format(printf, 2, 3))) explicit Error(const char *format, ...);
|
||||
|
||||
[[nodiscard]] const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
// Close file descriptors and delete allocated array memory
|
||||
class garbageCollector {
|
||||
private:
|
||||
@@ -214,7 +215,7 @@ public:
|
||||
};
|
||||
|
||||
Data *tuple_data = nullptr;
|
||||
Data tuple_data_type = { _Type1{}, _Type2{}, _Type3{}};
|
||||
Data tuple_data_type = {_Type1{}, _Type2{}, _Type3{}};
|
||||
size_t capacity{}, count{};
|
||||
|
||||
PureTuple() : tuple_data(new Data[20]), capacity(20), count(0) {}
|
||||
|
||||
@@ -42,9 +42,9 @@ Error::Error(const char *format, ...) {
|
||||
const char *Error::what() const noexcept { return _message.data(); }
|
||||
|
||||
Logger::Logger(const LogLevels level, const char *func, const char *file,
|
||||
const char *name, const char *sfile, const int line)
|
||||
: _level(level), _funcname(func), _logFile(file), _program_name(name),
|
||||
_file(sfile), _line(line) {}
|
||||
const char *name, const char *source_file, const int line)
|
||||
: _level(level), _function_name(func), _logFile(file), _program_name(name),
|
||||
_file(source_file), _line(line) {}
|
||||
|
||||
Logger::~Logger() {
|
||||
if (LoggingProperties::DISABLE) return;
|
||||
@@ -52,7 +52,7 @@ Logger::~Logger() {
|
||||
snprintf(str, sizeof(str), "<%c> [ <prog %s> <on %s:%d> %s %s] %s(): %s",
|
||||
static_cast<char>(_level), _program_name,
|
||||
basename(const_cast<char *>(_file)), _line, currentDate().data(),
|
||||
currentTime().data(), _funcname, _oss.str().data());
|
||||
currentTime().data(), _function_name, _oss.str().data());
|
||||
|
||||
if (!isExists(_logFile)) {
|
||||
if (const int fd =
|
||||
|
||||
Reference in New Issue
Block a user