Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions include/logit_cpp/logit/Logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ namespace logit {

LoggerReadLock lock(m_loggers_mx);
if (targeted) {
if (record.logger_index < (int)m_loggers.size())
if (record.logger_index < static_cast<int>(m_loggers.size()))
snapshot.push_back(m_loggers[record.logger_index]);
} else {
snapshot = m_loggers; // copy shared_ptrs
Expand All @@ -179,7 +179,7 @@ namespace logit {

std::lock_guard<std::mutex> exec_lock(strategy->exec_mx);
if (!strategy->enabled) return;
if ((int)record.log_level < (int)strategy->logger->get_log_level()) return;
if (static_cast<int>(record.log_level) < static_cast<int>(strategy->logger->get_log_level())) return;
dispatch_to_strategy(*strategy, record);
return;
}
Expand All @@ -190,7 +190,7 @@ namespace logit {
std::lock_guard<std::mutex> exec_lock(strategy->exec_mx);
if (strategy->single_mode) continue;
if (!strategy->enabled) continue;
if ((int)record.log_level < (int)strategy->logger->get_log_level()) continue;
if (static_cast<int>(record.log_level) < static_cast<int>(strategy->logger->get_log_level())) continue;

dispatch_to_strategy(*strategy, record);
}
Expand Down
6 changes: 4 additions & 2 deletions include/logit_cpp/logit/loggers/ConsoleLogger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,10 @@ namespace logit {
/// \return A double representing the requested parameter, or 0.0 if the parameter is unsupported.
double get_float_param(const LoggerParam& param) const override {
switch (param) {
case LoggerParam::LastLogTimestamp: return (double)get_last_log_ts() / 1000.0;
case LoggerParam::TimeSinceLastLog: return (double)get_time_since_last_log() / 1000.0;
case LoggerParam::LastLogTimestamp:
return static_cast<double>(get_last_log_ts()) / 1000.0;
case LoggerParam::TimeSinceLastLog:
return static_cast<double>(get_time_since_last_log()) / 1000.0;
default:
break;
};
Expand Down
12 changes: 6 additions & 6 deletions include/logit_cpp/logit/loggers/EventLogLogger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ namespace logit {
LogLevel lvl = rec.log_level;
std::string s = msg;
auto task = [this, lvl, s]() {
if ((int)lvl < m_level.load()) return;
if (static_cast<int>(lvl) < m_level.load()) return;
if (!m_hsrc) return;
WORD type = m_map(lvl);
int n = MultiByteToWideChar(CP_UTF8, 0, s.c_str(), (int)s.size(), nullptr, 0);
int n = MultiByteToWideChar(CP_UTF8, 0, s.c_str(), static_cast<int>(s.size()), nullptr, 0);
std::wstring wmsg; wmsg.resize(n);
MultiByteToWideChar(CP_UTF8, 0, s.c_str(), (int)s.size(), &wmsg[0], n);
MultiByteToWideChar(CP_UTF8, 0, s.c_str(), static_cast<int>(s.size()), &wmsg[0], n);
LPCWSTR arr[1] = { wmsg.c_str() };
ReportEventW(m_hsrc, type, 0, 0, nullptr, 1, 0, arr, nullptr);
};
Expand All @@ -91,11 +91,11 @@ namespace logit {

/// \brief Set minimal log level.
/// \param l New level.
void set_log_level(LogLevel l) override { m_level.store((int)l); }
void set_log_level(LogLevel l) override { m_level.store(static_cast<int>(l)); }

/// \brief Get current log level.
/// \return Minimal log level.
LogLevel get_log_level() const override { return (LogLevel)m_level.load(); }
LogLevel get_log_level() const override { return static_cast<LogLevel>(m_level.load()); }

/// \brief Wait for asynchronous tasks to finish.
void wait() override { if (m_cfg.async) detail::TaskExecutor::get_instance().wait(); }
Expand All @@ -113,7 +113,7 @@ namespace logit {
}
Config m_cfg{};
HANDLE m_hsrc = nullptr;
std::atomic<int> m_level{(int)LogLevel::LOG_LVL_TRACE};
std::atomic<int> m_level{static_cast<int>(LogLevel::LOG_LVL_TRACE)};
std::atomic<int64_t> m_last_ts{0};
};

Expand Down
6 changes: 4 additions & 2 deletions include/logit_cpp/logit/loggers/FileLogger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,10 @@ namespace logit {
/// \return A double representing the requested parameter, or 0.0 if the parameter is unsupported.
double get_float_param(const LoggerParam& param) const override {
switch (param) {
case LoggerParam::LastLogTimestamp: return (double)get_last_log_ts() / 1000.0;
case LoggerParam::TimeSinceLastLog: return (double)get_time_since_last_log() / 1000.0;
case LoggerParam::LastLogTimestamp:
return static_cast<double>(get_last_log_ts()) / 1000.0;
case LoggerParam::TimeSinceLastLog:
return static_cast<double>(get_time_since_last_log()) / 1000.0;
default:
break;
};
Expand Down
8 changes: 4 additions & 4 deletions include/logit_cpp/logit/loggers/SyslogLogger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ namespace logit {
LogLevel lvl = rec.log_level;
std::string s = msg;
auto task = [this, lvl, s]() {
if ((int)lvl < m_level.load()) return;
if (static_cast<int>(lvl) < m_level.load()) return;
syslog(m_map(lvl), "%s", s.c_str());
};
if (m_cfg.async) { detail::TaskExecutor::get_instance().add_task(task); }
Expand All @@ -88,11 +88,11 @@ namespace logit {

/// \brief Set minimal log level.
/// \param l New level.
void set_log_level(LogLevel l) override { m_level.store((int)l); }
void set_log_level(LogLevel l) override { m_level.store(static_cast<int>(l)); }

/// \brief Get current log level.
/// \return Minimal log level.
LogLevel get_log_level() const override { return (LogLevel)m_level.load(); }
LogLevel get_log_level() const override { return static_cast<LogLevel>(m_level.load()); }

/// \brief Wait for asynchronous tasks to finish.
void wait() override { if (m_cfg.async) detail::TaskExecutor::get_instance().wait(); }
Expand All @@ -109,7 +109,7 @@ namespace logit {
} return LOG_INFO;
}
Config m_cfg{};
std::atomic<int> m_level{(int)LogLevel::LOG_LVL_TRACE};
std::atomic<int> m_level{static_cast<int>(LogLevel::LOG_LVL_TRACE)};
std::atomic<int64_t> m_last_ts{0};
};

Expand Down
6 changes: 4 additions & 2 deletions include/logit_cpp/logit/loggers/UniqueFileLogger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,10 @@ namespace logit {
/// \return A double representing the requested parameter, or 0.0 if the parameter is unsupported.
double get_float_param(const LoggerParam& param) const override {
switch (param) {
case LoggerParam::LastLogTimestamp: return (double)get_last_log_ts() / 1000.0;
case LoggerParam::TimeSinceLastLog: return (double)get_time_since_last_log() / 1000.0;
case LoggerParam::LastLogTimestamp:
return static_cast<double>(get_last_log_ts()) / 1000.0;
case LoggerParam::TimeSinceLastLog:
return static_cast<double>(get_time_since_last_log()) / 1000.0;
default:
break;
};
Expand Down