Fixed tidy warnings

This commit is contained in:
gabime 2024-11-30 12:53:19 +02:00
parent 7a0e2ff8a8
commit 0d8f1f1dd4
7 changed files with 12 additions and 12 deletions

View File

@ -25,10 +25,10 @@ public:
void open(const filename_t &fname, bool truncate = false);
void reopen(bool truncate);
void flush();
void sync();
void flush() const;
void sync() const;
void close();
void write(const memory_buf_t &buf);
void write(const memory_buf_t &buf) const;
size_t size() const;
const filename_t &filename() const;

View File

@ -45,7 +45,7 @@ public:
// This make the default API faster, but cannot be used concurrently with set_default_logger().
// e.g do not call set_default_logger() from one thread while calling spdlog::info() from
// another.
logger *get_default_raw();
logger *get_default_raw() const;
// set default logger.
// default logger is stored in default_logger_ (for faster retrieval) and in the loggers_ map.

View File

@ -32,7 +32,7 @@ public:
void set_color(level color_level, string_view_t color);
void set_color_mode(color_mode mode);
bool should_color();
bool should_color() const;
// Formatting codes
static constexpr std::string_view reset = "\033[m";

View File

@ -43,7 +43,7 @@ private:
// delete the target if exists, and rename the src file to target
// return true on success, false otherwise.
bool rename_file_(const filename_t &src_filename, const filename_t &target_filename);
static bool rename_file_(const filename_t &src_filename, const filename_t &target_filename);
filename_t base_filename_;
std::size_t max_size_;

View File

@ -62,13 +62,13 @@ void file_helper::reopen(bool truncate) {
this->open(filename_, truncate);
}
void file_helper::flush() {
void file_helper::flush() const {
if (std::fflush(fd_) != 0) {
throw_spdlog_ex("Failed flush to file " + os::filename_to_str(filename_), errno);
}
}
void file_helper::sync() {
void file_helper::sync() const {
if (!os::fsync(fd_)) {
throw_spdlog_ex("Failed to fsync file " + os::filename_to_str(filename_), errno);
}
@ -89,9 +89,9 @@ void file_helper::close() {
}
}
void file_helper::write(const memory_buf_t &buf) {
void file_helper::write(const memory_buf_t &buf) const {
if (fd_ == nullptr) return;
size_t msg_size = buf.size();
const size_t msg_size = buf.size();
const auto *data = buf.data();
if (std::fwrite(data, 1, msg_size, fd_) != msg_size) {
throw_spdlog_ex("Failed writing to file " + os::filename_to_str(filename_), errno);

View File

@ -113,7 +113,7 @@ std::shared_ptr<logger> registry::default_logger() {
// To be used directly by the spdlog default api (e.g. spdlog::info)
// This make the default API faster, but cannot be used concurrently with set_default_logger().
// e.g do not call set_default_logger() from one thread while calling spdlog::info() from another.
logger *registry::get_default_raw() { return default_logger_.get(); }
logger *registry::get_default_raw() const { return default_logger_.get(); }
// set default logger.
// default logger is stored in default_logger_ (for faster retrieval) and in the loggers_ map.

View File

@ -34,7 +34,7 @@ void ansicolor_sink<Mutex>::set_color(level color_level, string_view_t color) {
}
template <typename Mutex>
bool ansicolor_sink<Mutex>::should_color() {
bool ansicolor_sink<Mutex>::should_color() const {
return should_do_colors_;
}