Skip to content

Commit

Permalink
format all files
Browse files Browse the repository at this point in the history
  • Loading branch information
odygrd committed Oct 10, 2024
1 parent 83da778 commit 664fc05
Show file tree
Hide file tree
Showing 46 changed files with 118 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ void setup_quill(char const* log_file)
quill::Frontend::create_or_get_logger(
"root", std::move(console_sink),
quill::PatternFormatterOptions{"%(time) [%(thread_id)] %(short_source_location:<28) "
"LOG_%(log_level:<9) %(logger:<12) %(message)",
"LOG_%(log_level:<9) %(logger:<12) %(message)",
"%H:%M:%S.%Qns", quill::Timezone::GmtTime});
}
2 changes: 1 addition & 1 deletion examples/backend_tsc_clock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ int main()
auto const tsc_start_seconds = std::chrono::duration_cast<std::chrono::seconds>(
quill::BackendTscClock::to_time_point(tsc_start).time_since_epoch())
.count();

auto const tsc_end_seconds = std::chrono::duration_cast<std::chrono::seconds>(
quill::BackendTscClock::to_time_point(tsc_end).time_since_epoch())
.count();
Expand Down
2 changes: 1 addition & 1 deletion examples/file_logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ int main()
quill::Logger* logger = quill::Frontend::create_or_get_logger(
"root", std::move(file_sink),
quill::PatternFormatterOptions{"%(time) [%(thread_id)] %(short_source_location:<28) "
"LOG_%(log_level:<9) %(logger:<12) %(message)",
"LOG_%(log_level:<9) %(logger:<12) %(message)",
"%H:%M:%S.%Qns", quill::Timezone::GmtTime});

// set the log level of the logger to debug (default is info)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ void setup_quill(char const* log_file)
global_logger_a = quill::Frontend::create_or_get_logger(
"root", std::move(file_sink),
quill::PatternFormatterOptions{"%(time) [%(thread_id)] %(short_source_location:<28) "
"LOG_%(log_level:<9) %(logger:<12) %(message)",
"LOG_%(log_level:<9) %(logger:<12) %(message)",
"%H:%M:%S.%Qns", quill::Timezone::GmtTime});
}
2 changes: 1 addition & 1 deletion examples/rotating_file_logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ int main()
quill::Logger* logger = quill::Frontend::create_or_get_logger(
"root", std::move(rotating_file_sink),
quill::PatternFormatterOptions{"%(time) [%(thread_id)] %(short_source_location:<28) "
"LOG_%(log_level:<9) %(logger:<12) %(message)",
"LOG_%(log_level:<9) %(logger:<12) %(message)",
"%H:%M:%S.%Qns", quill::Timezone::GmtTime});

for (int i = 0; i < 20; ++i)
Expand Down
4 changes: 2 additions & 2 deletions examples/shared_library/example_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ int main()
// Change the LogLevel to print everything
global_logger_a->set_log_level(quill::LogLevel::TraceL3);

std::string s {"string"};
std::string_view sv {"string_view"};
std::string s{"string"};
std::string_view sv{"string_view"};

LOG_TRACE_L3(global_logger_a, "This is a log trace l3 example {}", 1);
LOG_TRACE_L2(global_logger_a, "This is a log trace l2 example {} {}", 2, 2.3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ void setup_quill()
global_logger_a = quill::Frontend::create_or_get_logger(
"root", std::move(console_sink),
quill::PatternFormatterOptions{"%(time) [%(thread_id)] %(short_source_location:<28) "
"LOG_%(log_level:<9) %(logger:<12) %(message)",
"LOG_%(log_level:<9) %(logger:<12) %(message)",
"%H:%M:%S.%Qns", quill::Timezone::GmtTime});
}
2 changes: 1 addition & 1 deletion examples/signal_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ int main()
}

// After 10 messages Crash - Uncomment any of the below :

// illegal_instruction(logger);
// cause_segfault(logger);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,19 @@ class RotatingFileSinkWithFormatter : public quill::RotatingFileSink
{
}

void write_log(quill::MacroMetadata const* log_metadata, uint64_t log_timestamp, std::string_view thread_id,
std::string_view thread_name, std::string const& process_id,
std::string_view logger_name, quill::LogLevel log_level,
void write_log(quill::MacroMetadata const* log_metadata, uint64_t log_timestamp,
std::string_view thread_id, std::string_view thread_name,
std::string const& process_id, std::string_view logger_name, quill::LogLevel log_level,
std::string_view log_level_description, std::string_view log_level_short_code,
std::vector<std::pair<std::string, std::string>> const* named_args,
std::string_view log_message, std::string_view) override
std::string_view log_message, std::string_view) override
{
std::string_view const formatted_log_statement =
_formatter.format(log_timestamp, thread_id, thread_name, process_id, logger_name, log_level_description,
log_level_short_code, *log_metadata, named_args, log_message);

quill::RotatingFileSink::write_log(log_metadata, log_timestamp, thread_id, thread_name, process_id, logger_name, log_level,
quill::RotatingFileSink::write_log(
log_metadata, log_timestamp, thread_id, thread_name, process_id, logger_name, log_level,
log_level_description, log_level_short_code, named_args, log_message, formatted_log_statement);
}

Expand Down
2 changes: 1 addition & 1 deletion examples/user_defined_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class UserFilter : public quill::Filter
{
public:
UserFilter() : quill::Filter("filter_1"){};
UserFilter() : quill::Filter("filter_1") {};

bool filter(quill::MacroMetadata const* /** log_metadata **/, uint64_t /** log_timestamp **/,
std::string_view /** thread_id **/, std::string_view /** thread_name **/,
Expand Down
2 changes: 1 addition & 1 deletion examples/user_defined_types_logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class User
{
public:
User(std::string name, std::string surname, uint32_t age)
: name(std::move(name)), surname(std::move(surname)), age(age){};
: name(std::move(name)), surname(std::move(surname)), age(age) {};

friend std::ostream& operator<<(std::ostream& os, User const& obj)
{
Expand Down
6 changes: 3 additions & 3 deletions include/quill/CsvWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ class CsvWriter
*/
CsvWriter(std::string const& unique_name, std::initializer_list<std::shared_ptr<Sink>> sinks)
{
_logger = Frontend::create_or_get_logger(
_logger_name_prefix + unique_name, sinks, PatternFormatterOptions{"%(message)", "", Timezone::GmtTime});
_logger = Frontend::create_or_get_logger(_logger_name_prefix + unique_name, sinks,
PatternFormatterOptions{"%(message)", "", Timezone::GmtTime});

_logger->template log_statement<false, false>(LogLevel::None, &_header_metadata, TCsvSchema::header);
}
Expand Down Expand Up @@ -127,7 +127,7 @@ class CsvWriter
static constexpr MacroMetadata _line_metadata{
"", "", TCsvSchema::format, nullptr, LogLevel::Info, MacroMetadata::Event::Log};

static inline std::string _logger_name_prefix {"__csv__"};
static inline std::string _logger_name_prefix{"__csv__"};

LoggerImpl<TFrontendOptions>* _logger{nullptr};
};
Expand Down
66 changes: 33 additions & 33 deletions include/quill/LogMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,15 +302,15 @@
quill::MacroMetadata::Event::Log \
}

#define QUILL_LOGGER_CALL(likelyhood, logger, tags, log_level, fmt, ...) \
do \
{ \
if (likelyhood(logger->template should_log_statement<log_level>())) \
{ \
#define QUILL_LOGGER_CALL(likelyhood, logger, tags, log_level, fmt, ...) \
do \
{ \
if (likelyhood(logger->template should_log_statement<log_level>())) \
{ \
QUILL_DEFINE_MACRO_METADATA(__FUNCTION__, fmt, tags, log_level); \
logger->template log_statement<QUILL_IMMEDIATE_FLUSH, false>( \
quill::LogLevel::None, &macro_metadata, ##__VA_ARGS__); \
} \
} \
} while (0)

#define QUILL_LOGGER_CALL_LIMIT(min_interval, likelyhood, logger, tags, log_level, fmt, ...) \
Expand All @@ -331,29 +331,29 @@
} \
} while (0)

#define QUILL_BACKTRACE_LOGGER_CALL(logger, tags, fmt, ...) \
do \
{ \
if (QUILL_LIKELY(logger->template should_log_statement<quill::LogLevel::Backtrace>())) \
{ \
#define QUILL_BACKTRACE_LOGGER_CALL(logger, tags, fmt, ...) \
do \
{ \
if (QUILL_LIKELY(logger->template should_log_statement<quill::LogLevel::Backtrace>())) \
{ \
QUILL_DEFINE_MACRO_METADATA(__FUNCTION__, fmt, tags, quill::LogLevel::Backtrace); \
logger->template log_statement<QUILL_IMMEDIATE_FLUSH, false>( \
quill::LogLevel::None, &macro_metadata, ##__VA_ARGS__); \
} \
} \
} while (0)

/**
* Dynamic runtime log level with a tiny overhead
* @Note: Prefer using the compile time log level macros
*/
#define QUILL_DYNAMIC_LOGGER_CALL(logger, tags, log_level, fmt, ...) \
do \
{ \
if (logger->should_log_statement(log_level)) \
{ \
#define QUILL_DYNAMIC_LOGGER_CALL(logger, tags, log_level, fmt, ...) \
do \
{ \
if (logger->should_log_statement(log_level)) \
{ \
QUILL_DEFINE_MACRO_METADATA(__FUNCTION__, fmt, tags, quill::LogLevel::Dynamic); \
logger->template log_statement<QUILL_IMMEDIATE_FLUSH, true>(log_level, &macro_metadata, ##__VA_ARGS__); \
} \
} \
} while (0)

#if QUILL_COMPILE_ACTIVE_LOG_LEVEL <= QUILL_COMPILE_ACTIVE_LOG_LEVEL_TRACE_L3
Expand Down Expand Up @@ -585,37 +585,37 @@
#endif

#if QUILL_COMPILE_ACTIVE_LOG_LEVEL <= QUILL_COMPILE_ACTIVE_LOG_LEVEL_NOTICE
#define QUILL_LOG_NOTICE(logger, fmt, ...) \
#define QUILL_LOG_NOTICE(logger, fmt, ...) \
QUILL_LOGGER_CALL(QUILL_LIKELY, logger, nullptr, quill::LogLevel::Notice, fmt, ##__VA_ARGS__)

#define QUILL_LOG_NOTICE_LIMIT(min_interval, logger, fmt, ...) \
#define QUILL_LOG_NOTICE_LIMIT(min_interval, logger, fmt, ...) \
QUILL_LOGGER_CALL_LIMIT(min_interval, QUILL_LIKELY, logger, nullptr, quill::LogLevel::Notice, fmt, ##__VA_ARGS__)

#define QUILL_LOG_NOTICE_TAGS(logger, tags, fmt, ...) \
#define QUILL_LOG_NOTICE_TAGS(logger, tags, fmt, ...) \
QUILL_LOGGER_CALL(QUILL_LIKELY, logger, tags, quill::LogLevel::Notice, fmt, ##__VA_ARGS__)

#define QUILL_LOGV_NOTICE(logger, fmt, ...) \
QUILL_LOGGER_CALL(QUILL_LIKELY, logger, nullptr, quill::LogLevel::Notice, \
#define QUILL_LOGV_NOTICE(logger, fmt, ...) \
QUILL_LOGGER_CALL(QUILL_LIKELY, logger, nullptr, quill::LogLevel::Notice, \
QUILL_GENERATE_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__)

#define QUILL_LOGV_NOTICE_LIMIT(min_interval, logger, fmt, ...) \
QUILL_LOGGER_CALL_LIMIT(min_interval, QUILL_LIKELY, logger, nullptr, quill::LogLevel::Notice, \
#define QUILL_LOGV_NOTICE_LIMIT(min_interval, logger, fmt, ...) \
QUILL_LOGGER_CALL_LIMIT(min_interval, QUILL_LIKELY, logger, nullptr, quill::LogLevel::Notice, \
QUILL_GENERATE_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__)

#define QUILL_LOGV_NOTICE_TAGS(logger, tags, fmt, ...) \
QUILL_LOGGER_CALL(QUILL_LIKELY, logger, tags, quill::LogLevel::Notice, \
#define QUILL_LOGV_NOTICE_TAGS(logger, tags, fmt, ...) \
QUILL_LOGGER_CALL(QUILL_LIKELY, logger, tags, quill::LogLevel::Notice, \
QUILL_GENERATE_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__)

#define QUILL_LOGJ_NOTICE(logger, fmt, ...) \
QUILL_LOGGER_CALL(QUILL_LIKELY, logger, nullptr, quill::LogLevel::Notice, \
#define QUILL_LOGJ_NOTICE(logger, fmt, ...) \
QUILL_LOGGER_CALL(QUILL_LIKELY, logger, nullptr, quill::LogLevel::Notice, \
QUILL_GENERATE_NAMED_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__)

#define QUILL_LOGJ_NOTICE_LIMIT(min_interval, logger, fmt, ...) \
QUILL_LOGGER_CALL_LIMIT(min_interval, QUILL_LIKELY, logger, nullptr, quill::LogLevel::Notice, \
#define QUILL_LOGJ_NOTICE_LIMIT(min_interval, logger, fmt, ...) \
QUILL_LOGGER_CALL_LIMIT(min_interval, QUILL_LIKELY, logger, nullptr, quill::LogLevel::Notice, \
QUILL_GENERATE_NAMED_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__)

#define QUILL_LOGJ_NOTICE_TAGS(logger, tags, fmt, ...) \
QUILL_LOGGER_CALL(QUILL_LIKELY, logger, tags, quill::LogLevel::Notice, \
#define QUILL_LOGJ_NOTICE_TAGS(logger, tags, fmt, ...) \
QUILL_LOGGER_CALL(QUILL_LIKELY, logger, tags, quill::LogLevel::Notice, \
QUILL_GENERATE_NAMED_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__)
#else
#define QUILL_LOG_NOTICE(logger, fmt, ...) (void)0
Expand Down
8 changes: 4 additions & 4 deletions include/quill/StringRef.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ namespace utility
class StringRef
{
public:
explicit StringRef(std::string const& str) : _str_view(str){};
explicit StringRef(std::string_view str) : _str_view(str){};
explicit StringRef(char const* str) : _str_view(str, strlen(str)){};
StringRef(char const* str, size_t size) : _str_view(str, size){};
explicit StringRef(std::string const& str) : _str_view(str) {};
explicit StringRef(std::string_view str) : _str_view(str) {};
explicit StringRef(char const* str) : _str_view(str, strlen(str)) {};
StringRef(char const* str, size_t size) : _str_view(str, size) {};

QUILL_NODISCARD std::string_view const& get_string_view() const noexcept { return _str_view; }

Expand Down
4 changes: 2 additions & 2 deletions include/quill/backend/BackendOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ struct BackendOptions
* These names provide human-readable identifiers for each log level.
*/
std::array<std::string, 12> log_level_descriptions = {
"TRACE_L3", "TRACE_L2", "TRACE_L1", "DEBUG", "INFO", "NOTICE", "WARNING",
"ERROR", "CRITICAL", "BACKTRACE", "NONE", "DYNAMIC"};
"TRACE_L3", "TRACE_L2", "TRACE_L1", "DEBUG", "INFO", "NOTICE",
"WARNING", "ERROR", "CRITICAL", "BACKTRACE", "NONE", "DYNAMIC"};

/**
* @brief Short codes or identifiers for each log level.
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 @@ -32,7 +32,7 @@ class LoggerBase;
struct TransitEvent
{
using FormatBuffer = fmtquill::basic_memory_buffer<char, 88>;

/***/
TransitEvent() = default;

Expand Down
4 changes: 1 addition & 3 deletions include/quill/core/LoggerBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ class LoggerBase
* Returns the user-defined clock source.
* @return A pointer to the constant UserClockSource object.
*/
QUILL_NODISCARD UserClockSource* get_user_clock_source() const noexcept {
return user_clock;
}
QUILL_NODISCARD UserClockSource* get_user_clock_source() const noexcept { return user_clock; }

/**
* Returns the type of clock source being used.
Expand Down
2 changes: 1 addition & 1 deletion include/quill/core/SinkManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class SinkManager
{
explicit SinkInfo() = default;
SinkInfo(std::string sid, std::weak_ptr<Sink> sptr)
: sink_id(static_cast<std::string&&>(sid)), sink_ptr(static_cast<std::weak_ptr<Sink>&&>(sptr)){};
: sink_id(static_cast<std::string&&>(sid)), sink_ptr(static_cast<std::weak_ptr<Sink>&&>(sptr)) {};

std::string sink_id;
std::weak_ptr<Sink> sink_ptr;
Expand Down
8 changes: 3 additions & 5 deletions include/quill/core/ThreadContextManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,7 @@ class ThreadContext
void mark_invalid() noexcept { _valid.store(false, std::memory_order_relaxed); }

/***/
QUILL_NODISCARD bool is_valid() const noexcept {
return _valid.load(std::memory_order_relaxed);
}
QUILL_NODISCARD bool is_valid() const noexcept { return _valid.load(std::memory_order_relaxed); }

/***/
void increment_failure_counter() noexcept
Expand All @@ -199,8 +197,8 @@ class ThreadContext

SpscQueueUnion _spsc_queue_union; /**< queue for this thread */
SizeCacheVector _conditional_arg_size_cache; /**< cache for storing sizes needed for specific operations, such as when calling `strn` functions or when a loop is required e.g. caching the size of a type */
std::string _thread_id = std::to_string(get_thread_id()); /**< cached thread pid */
std::string _thread_name = get_thread_name(); /**< cached thread name */
std::string _thread_id = std::to_string(get_thread_id()); /**< cached thread pid */
std::string _thread_name = get_thread_name(); /**< cached thread name */
std::shared_ptr<TransitEventBuffer> _transit_event_buffer; /**< backend thread buffer. this could be unique_ptr but it is shared_ptr because of the forward declaration */
QueueType _queue_type;
std::atomic<bool> _valid{true}; /**< is this context valid, set by the frontend, read by the backend thread */
Expand Down
Loading

0 comments on commit 664fc05

Please sign in to comment.