Skip to content

Commit

Permalink
remove some unused includes and some other cosmetic changes
Browse files Browse the repository at this point in the history
  • Loading branch information
odygrd committed Dec 29, 2024
1 parent aecda26 commit cbadc19
Show file tree
Hide file tree
Showing 24 changed files with 39 additions and 54 deletions.
1 change: 0 additions & 1 deletion include/quill/Backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include <csignal>
#include <cstdint>
#include <cstdlib>
#include <initializer_list>
#include <mutex>

QUILL_BEGIN_NAMESPACE
Expand Down
2 changes: 0 additions & 2 deletions include/quill/CsvWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@

#include "quill/Frontend.h"
#include "quill/core/Attributes.h"
#include "quill/core/LoggerBase.h"
#include "quill/sinks/FileSink.h"
#include "quill/sinks/Sink.h"

#include <cstdint>
#include <memory>
#include <string>
#include <utility>
Expand Down
1 change: 0 additions & 1 deletion include/quill/Frontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

#include <cassert>
#include <cstddef>
#include <cstdint>
#include <initializer_list>
#include <memory>
#include <string>
Expand Down
6 changes: 3 additions & 3 deletions include/quill/backend/BackendManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace detail
/**
* Provides access to common collection class that are used by both the frontend and the backend
* components of the logging system
* There should only be only active active instance of this class which is achieved by the
* There should only be only active instance of this class which is achieved by the
* LogSystemManagerSingleton
*/
class BackendManager
Expand All @@ -43,8 +43,8 @@ class BackendManager
BackendManager& operator=(BackendManager const&) = delete;

private:
friend class quill::Backend;
friend class quill::BackendTscClock;
friend class Backend;
friend class BackendTscClock;

/***/
BackendManager() = default;
Expand Down
12 changes: 5 additions & 7 deletions include/quill/backend/BackendWorker.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "quill/backend/PatternFormatter.h"
#include "quill/backend/RdtscClock.h"
#include "quill/backend/ThreadUtilities.h"
#include "quill/backend/TimestampFormatter.h"
#include "quill/backend/TransitEvent.h"
#include "quill/backend/TransitEventBuffer.h"

Expand Down Expand Up @@ -55,7 +54,6 @@
#include <memory>
#include <mutex>
#include <optional>
#include <ratio>
#include <string>
#include <string_view>
#include <thread>
Expand Down Expand Up @@ -252,11 +250,11 @@ class BackendWorker

#if defined(_WIN32)
std::wstring const dummy = L"dummy";
QUILL_MAYBE_UNUSED static auto encode1 = detail::utf8_encode(dummy);
QUILL_MAYBE_UNUSED static auto encode1 = utf8_encode(dummy);
(void)encode1;

QUILL_MAYBE_UNUSED static auto encode2 =
detail::utf8_encode(reinterpret_cast<std::byte const*>(dummy.data()), dummy.size());
utf8_encode(reinterpret_cast<std::byte const*>(dummy.data()), dummy.size());
(void)encode2;
#endif
}
Expand Down Expand Up @@ -582,7 +580,7 @@ class BackendWorker
}
}

detail::FormatArgsDecoder format_args_decoder;
FormatArgsDecoder format_args_decoder;
std::memcpy(&format_args_decoder, read_pos, sizeof(format_args_decoder));
read_pos += sizeof(format_args_decoder);

Expand Down Expand Up @@ -887,11 +885,11 @@ class BackendWorker

// proceed after ensuring a pattern formatter exists
std::string_view const log_level_description =
detail::log_level_to_string(transit_event.log_level(), _options.log_level_descriptions.data(),
log_level_to_string(transit_event.log_level(), _options.log_level_descriptions.data(),
_options.log_level_descriptions.size());

std::string_view const log_level_short_code =
detail::log_level_to_string(transit_event.log_level(), _options.log_level_short_codes.data(),
log_level_to_string(transit_event.log_level(), _options.log_level_short_codes.data(),
_options.log_level_short_codes.size());

if (transit_event.logger_base->pattern_formatter->get_options().add_metadata_to_multi_line_logs &&
Expand Down
9 changes: 4 additions & 5 deletions include/quill/backend/SignalHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <initializer_list>
#include <string>

#if defined(_WIN32)
Expand Down Expand Up @@ -89,19 +88,19 @@ class SignalHandlerContext
}

/***/
QUILL_NODISCARD LoggerBase* get_logger() noexcept
QUILL_NODISCARD static LoggerBase* get_logger() noexcept
{
LoggerBase* logger_base{nullptr};

if (!SignalHandlerContext::instance().logger_name.empty())
if (!instance().logger_name.empty())
{
logger_base = detail::LoggerManager::instance().get_logger(SignalHandlerContext::instance().logger_name);
logger_base = LoggerManager::instance().get_logger(instance().logger_name);
}

// This also checks if the logger was found above
if (!logger_base || !logger_base->is_valid_logger())
{
logger_base = detail::LoggerManager::instance().get_valid_logger(SignalHandlerContext::excluded_logger_name_substr);
logger_base = LoggerManager::instance().get_valid_logger(excluded_logger_name_substr);
}

return logger_base;
Expand Down
4 changes: 2 additions & 2 deletions include/quill/backend/ThreadUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ ReturnT callRunTimeDynamicLinkedFunction(std::string const& dll_name,
// Windows Server 2016, Windows 10 LTSB 2016 and Windows 10 version 1607: e.g. GetThreadDescription is only available by Run Time Dynamic Linking in KernelBase.dll.

#ifdef UNICODE
HINSTANCE const hinstLibrary = LoadLibraryW(s2ws(dll_name).c_str());
const HINSTANCE hinstLibrary = LoadLibraryW(s2ws(dll_name).c_str());
#else
HINSTANCE const hinstLibrary = LoadLibraryA(dll_name.c_str());
const HINSTANCE hinstLibrary = LoadLibraryA(dll_name.c_str());
#endif

if (QUILL_UNLIKELY(hinstLibrary == nullptr))
Expand Down
2 changes: 1 addition & 1 deletion include/quill/backend/TimestampFormatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace detail
* 2) %Qus - Microseconds
* 3) %Qns - Nanoseconds
* @note %Qms, %Qus, %Qns specifiers are mutually exclusive
* e.g given : "%I:%M.%Qms%p" the output would be "03:21.343PM"
* e.g. given : "%I:%M.%Qms%p" the output would be "03:21.343PM"
*/
class TimestampFormatter
{
Expand Down
2 changes: 1 addition & 1 deletion include/quill/backend/TransitEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ struct TransitEvent

uint64_t timestamp{0};
MacroMetadata const* macro_metadata{nullptr};
detail::LoggerBase* logger_base{nullptr};
LoggerBase* logger_base{nullptr};
std::unique_ptr<FormatBuffer> formatted_msg{std::make_unique<FormatBuffer>()}; /** buffer for message **/
std::unique_ptr<std::vector<std::pair<std::string, std::string>>> named_args; /** A unique ptr to save space as named args feature is not always used */
std::atomic<bool>* flush_flag{nullptr}; /** This is only used in the case of Event::Flush **/
Expand Down
4 changes: 0 additions & 4 deletions include/quill/backend/TransitEventBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
#include "quill/core/Attributes.h"
#include "quill/core/MathUtilities.h"

#include <cassert>
#include <cstdint>
#include <vector>

QUILL_BEGIN_NAMESPACE

namespace detail
Expand Down
4 changes: 2 additions & 2 deletions include/quill/backend/Utf8Conv.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ namespace detail
/**
* @brief Convert a wide Unicode string to a UTF-8 encoded string.
*
* @param input_string_data Pointer to the wide string data.
* @param input_string_length Length of the wide string.
* @param data Pointer to the wide string data.
* @param wide_str_len Length of the wide string.
* @return The UTF-8 encoded string.
*
* @remarks If the input string is empty or the conversion fails, an empty string is returned.
Expand Down
1 change: 1 addition & 0 deletions include/quill/core/BoundedSPSCQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ class BoundedSPSCQueueImpl
/**
* align a pointer to the given alignment
* @param pointer a pointer the object
* @param alignment a pointer the object
* @return an aligned pointer for the given object
*/
QUILL_NODISCARD static std::byte* _align_pointer(void* pointer, size_t alignment) noexcept
Expand Down
21 changes: 10 additions & 11 deletions include/quill/core/Codec.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include <string>
#include <string_view>
#include <type_traits>
#include <vector>

QUILL_BEGIN_NAMESPACE

Expand Down Expand Up @@ -87,7 +86,7 @@ void codec_not_found_for_type()

QUILL_NODISCARD inline size_t safe_strnlen(char const* str, size_t maxlen) noexcept
{
char const* end = static_cast<char const*>(std::memchr(str, '\0', maxlen));
auto end = static_cast<char const*>(std::memchr(str, '\0', maxlen));
return end ? static_cast<size_t>(end - str) : maxlen;
}

Expand Down Expand Up @@ -216,7 +215,7 @@ struct Codec
std::conjunction<std::is_array<Arg>, std::is_same<detail::remove_cvref_t<std::remove_extent_t<Arg>>, char>>>)
{
// c strings or char array
char const* arg = reinterpret_cast<char const*>(buffer);
auto arg = reinterpret_cast<char const*>(buffer);
buffer += strlen(arg) + 1; // for c_strings we add +1 to the length as we also want to copy the null terminated char
return arg;
}
Expand All @@ -226,7 +225,7 @@ struct Codec
uint32_t len;
std::memcpy(&len, buffer, sizeof(len));
buffer += sizeof(len);
std::string_view const arg = std::string_view{reinterpret_cast<char const*>(buffer), len};
auto const arg = std::string_view{reinterpret_cast<char const*>(buffer), len};
buffer += len;
return arg;
}
Expand Down Expand Up @@ -282,12 +281,12 @@ namespace detail
*/
template <typename... Args>
QUILL_NODISCARD QUILL_ATTRIBUTE_HOT size_t compute_encoded_size_and_cache_string_lengths(
QUILL_MAYBE_UNUSED detail::SizeCacheVector& conditional_arg_size_cache, Args const&... args) noexcept
QUILL_MAYBE_UNUSED SizeCacheVector& conditional_arg_size_cache, Args const&... args) noexcept
{
if constexpr (!std::conjunction_v<std::disjunction<
std::is_arithmetic<detail::remove_cvref_t<Args>>, std::is_enum<detail::remove_cvref_t<Args>>,
std::is_same<detail::remove_cvref_t<Args>, void const*>, detail::is_std_string<detail::remove_cvref_t<Args>>,
std::is_same<detail::remove_cvref_t<Args>, std::string_view>>...>)
std::is_arithmetic<remove_cvref_t<Args>>, std::is_enum<remove_cvref_t<Args>>,
std::is_same<remove_cvref_t<Args>, void const*>, is_std_string<remove_cvref_t<Args>>,
std::is_same<remove_cvref_t<Args>, std::string_view>>...>)
{
// Clear the cache whenever processing involves non-fundamental types,
// or when the arguments are not of type std::string or std::string_view.
Expand All @@ -298,7 +297,7 @@ QUILL_NODISCARD QUILL_ATTRIBUTE_HOT size_t compute_encoded_size_and_cache_string
// Avoid using a fold expression with '+ ...' because we require a guaranteed evaluation
// order to ensure that each argument is processed in sequence. This is essential for
// correctly populating the conditional_arg_size_cache
((total_sum += Codec<detail::remove_cvref_t<Args>>::compute_encoded_size(conditional_arg_size_cache, args)), ...);
((total_sum += Codec<remove_cvref_t<Args>>::compute_encoded_size(conditional_arg_size_cache, args)), ...);
return total_sum;
}

Expand All @@ -309,11 +308,11 @@ QUILL_NODISCARD QUILL_ATTRIBUTE_HOT size_t compute_encoded_size_and_cache_string
* @param args The arguments to be encoded.
*/
template <typename... Args>
QUILL_ATTRIBUTE_HOT void encode(std::byte*& buffer, detail::SizeCacheVector const& conditional_arg_size_cache,
QUILL_ATTRIBUTE_HOT void encode(std::byte*& buffer, SizeCacheVector const& conditional_arg_size_cache,
Args const&... args) noexcept
{
QUILL_MAYBE_UNUSED uint32_t conditional_arg_size_cache_index{0};
(Codec<detail::remove_cvref_t<Args>>::encode(buffer, conditional_arg_size_cache,
(Codec<remove_cvref_t<Args>>::encode(buffer, conditional_arg_size_cache,
conditional_arg_size_cache_index, args),
...);
}
Expand Down
4 changes: 1 addition & 3 deletions include/quill/core/InlinedVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@

#pragma once

#include <cassert>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <type_traits>

#include "quill/core/Attributes.h"
Expand Down Expand Up @@ -171,7 +169,7 @@ class InlinedVector
* The capacity of 12 is chosen to fit within a full cache line for better performance.
*/
using SizeCacheVector = InlinedVector<uint32_t, 12>;
static_assert(sizeof(SizeCacheVector) <= detail::CACHE_LINE_SIZE,
static_assert(sizeof(SizeCacheVector) <= CACHE_LINE_SIZE,
"SizeCacheVector should not exceed a cache line");
} // namespace detail

Expand Down
1 change: 0 additions & 1 deletion include/quill/core/MacroMetadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "quill/core/Common.h"
#include "quill/core/LogLevel.h"

#include <cassert>
#include <cstddef>
#include <cstdint>
#include <string_view>
Expand Down
2 changes: 1 addition & 1 deletion include/quill/core/PatternFormatterOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include "quill/core/Attributes.h"
#include "quill/core/Common.h"
#include <cstdint>

#include <string>

QUILL_BEGIN_NAMESPACE
Expand Down
2 changes: 0 additions & 2 deletions include/quill/core/UnboundedSPSCQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@
#include "quill/core/Attributes.h"
#include "quill/core/BoundedSPSCQueue.h"
#include "quill/core/Common.h"
#include "quill/core/MathUtilities.h"
#include "quill/core/QuillError.h"

#include <atomic>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <string>

QUILL_BEGIN_NAMESPACE
Expand Down
2 changes: 1 addition & 1 deletion include/quill/sinks/ConsoleSink.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include "quill/core/Attributes.h"
#include "quill/core/LogLevel.h"
#include "quill/core/QuillError.h"
#include "quill/sinks/StreamSink.h"

#include <array>
Expand Down Expand Up @@ -316,6 +315,7 @@ class ConsoleSink : public StreamSink
* @param log_level_short_code Short code representing the log level.
* @param named_args vector of key-value pairs of named args
* @param log_message log message
* @param log_statement log statement
*/
QUILL_ATTRIBUTE_HOT void write_log(MacroMetadata const* log_metadata, uint64_t log_timestamp,
std::string_view thread_id, std::string_view thread_name,
Expand Down
3 changes: 3 additions & 0 deletions include/quill/sinks/FileSink.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ class FileSink : public StreamSink
* @param config Configuration for the FileSink.
* @param file_event_notifier Notifies on file events.
* @param do_fopen If false, the file will not be opened.
* @param start_time start time
*/
explicit FileSink(fs::path const& filename, FileSinkConfig const& config = FileSinkConfig{},
FileEventNotifier file_event_notifier = FileEventNotifier{}, bool do_fopen = true,
Expand Down Expand Up @@ -421,7 +422,9 @@ class FileSink : public StreamSink
* Get the filename with appended date and/or time.
* @param filename Path to the file.
* @param append_to_filename_option Append option.
* @param append_filename_format_pattern Append filename format option.
* @param time_zone Timezone to use.
* @param timestamp timestamp
* @return Updated filename.
*/
QUILL_NODISCARD static fs::path _get_updated_filename_with_appended_datetime(
Expand Down
2 changes: 2 additions & 0 deletions include/quill/sinks/JsonSink.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class JsonSink : public TBase
* @param log_level_description Description of the log level.
* @param log_level_short_code Short code representing the log level.
* @param named_args Vector of key-value pairs of named args
* @param log_message log message
* @param log_statement log statement
*/
QUILL_ATTRIBUTE_HOT void write_log(MacroMetadata const* log_metadata, uint64_t log_timestamp,
std::string_view thread_id, std::string_view thread_name,
Expand Down
3 changes: 2 additions & 1 deletion include/quill/sinks/RotatingFileSink.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include <ctime>
#include <deque>
#include <limits>
#include <ratio>
#include <string>
#include <string_view>
#include <system_error>
Expand Down Expand Up @@ -300,6 +299,8 @@ class RotatingFileSink : public FileSink
* @param thread_id The ID of the thread that generated the log message
* @param thread_name The name of the thread that generated the log message
* @param process_id Process Id
* @param logger_name logger name
* @param logger_name logger name
* @param log_level Log level of the message.
* @param log_level_description Description of the log level.
* @param log_level_short_code Short code representing the log level.
Expand Down
3 changes: 0 additions & 3 deletions include/quill/std/Optional.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include <cstddef>
#include <cstdint>
#include <optional>
#include <vector>

#if defined(_WIN32)
#include <string>
Expand All @@ -31,8 +30,6 @@ struct Codec<std::optional<T>>
static size_t compute_encoded_size(detail::SizeCacheVector& conditional_arg_size_cache,
std::optional<T> const& arg) noexcept
{
// We need to store the size of the vector in the buffer, so we reserve space for it.
// We add sizeof(bool) bytes to accommodate the size information.
size_t total_size{sizeof(bool)};

if (arg.has_value())
Expand Down
Loading

0 comments on commit cbadc19

Please sign in to comment.