mirror of
https://github.com/LizardByte/Sunshine.git
synced 2025-08-10 00:52:16 +00:00
style: adjust clang-format rules (#2186)
Co-authored-by: Vithorio Polten <reach@vithor.io>
This commit is contained in:
@@ -47,15 +47,13 @@ namespace logging {
|
||||
deinit();
|
||||
}
|
||||
|
||||
void
|
||||
deinit() {
|
||||
void deinit() {
|
||||
log_flush();
|
||||
bl::core::get()->remove_sink(sink);
|
||||
sink.reset();
|
||||
}
|
||||
|
||||
void
|
||||
formatter(const boost::log::record_view &view, boost::log::formatting_ostream &os) {
|
||||
void formatter(const boost::log::record_view &view, boost::log::formatting_ostream &os) {
|
||||
constexpr const char *message = "Message";
|
||||
constexpr const char *severity = "Severity";
|
||||
|
||||
@@ -90,7 +88,8 @@ namespace logging {
|
||||
|
||||
auto now = std::chrono::system_clock::now();
|
||||
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
now - std::chrono::time_point_cast<std::chrono::seconds>(now));
|
||||
now - std::chrono::time_point_cast<std::chrono::seconds>(now)
|
||||
);
|
||||
|
||||
auto t = std::chrono::system_clock::to_time_t(now);
|
||||
auto lt = *std::localtime(&t);
|
||||
@@ -99,8 +98,7 @@ namespace logging {
|
||||
<< log_type << view.attribute_values()[message].extract<std::string>();
|
||||
}
|
||||
|
||||
[[nodiscard]] std::unique_ptr<deinit_t>
|
||||
init(int min_log_level, const std::string &log_file) {
|
||||
[[nodiscard]] std::unique_ptr<deinit_t> init(int min_log_level, const std::string &log_file) {
|
||||
if (sink) {
|
||||
// Deinitialize the logging system before reinitializing it. This can probably only ever be hit in tests.
|
||||
deinit();
|
||||
@@ -112,7 +110,7 @@ namespace logging {
|
||||
sink = boost::make_shared<text_sink>();
|
||||
|
||||
#ifndef SUNSHINE_TESTS
|
||||
boost::shared_ptr<std::ostream> stream { &std::cout, boost::null_deleter() };
|
||||
boost::shared_ptr<std::ostream> stream {&std::cout, boost::null_deleter()};
|
||||
sink->locked_backend()->add_stream(stream);
|
||||
#endif
|
||||
sink->locked_backend()->add_stream(boost::make_shared<std::ofstream>(log_file));
|
||||
@@ -127,12 +125,10 @@ namespace logging {
|
||||
return std::make_unique<deinit_t>();
|
||||
}
|
||||
|
||||
void
|
||||
setup_av_logging(int min_log_level) {
|
||||
void setup_av_logging(int min_log_level) {
|
||||
if (min_log_level >= 1) {
|
||||
av_log_set_level(AV_LOG_QUIET);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
av_log_set_level(AV_LOG_DEBUG);
|
||||
}
|
||||
av_log_set_callback([](void *ptr, int level, const char *fmt, va_list vl) {
|
||||
@@ -144,28 +140,23 @@ namespace logging {
|
||||
// We print AV_LOG_FATAL at the error level. FFmpeg prints things as fatal that
|
||||
// are expected in some cases, such as lack of codec support or similar things.
|
||||
BOOST_LOG(error) << buffer;
|
||||
}
|
||||
else if (level <= AV_LOG_WARNING) {
|
||||
} else if (level <= AV_LOG_WARNING) {
|
||||
BOOST_LOG(warning) << buffer;
|
||||
}
|
||||
else if (level <= AV_LOG_INFO) {
|
||||
} else if (level <= AV_LOG_INFO) {
|
||||
BOOST_LOG(info) << buffer;
|
||||
}
|
||||
else if (level <= AV_LOG_VERBOSE) {
|
||||
} else if (level <= AV_LOG_VERBOSE) {
|
||||
// AV_LOG_VERBOSE is less verbose than AV_LOG_DEBUG
|
||||
BOOST_LOG(debug) << buffer;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
BOOST_LOG(verbose) << buffer;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void
|
||||
setup_libdisplaydevice_logging(int min_log_level) {
|
||||
constexpr int min_level { static_cast<int>(display_device::Logger::LogLevel::verbose) };
|
||||
constexpr int max_level { static_cast<int>(display_device::Logger::LogLevel::fatal) };
|
||||
const auto log_level { static_cast<display_device::Logger::LogLevel>(std::min(std::max(min_level, min_log_level), max_level)) };
|
||||
void setup_libdisplaydevice_logging(int min_log_level) {
|
||||
constexpr int min_level {static_cast<int>(display_device::Logger::LogLevel::verbose)};
|
||||
constexpr int max_level {static_cast<int>(display_device::Logger::LogLevel::fatal)};
|
||||
const auto log_level {static_cast<display_device::Logger::LogLevel>(std::min(std::max(min_level, min_log_level), max_level))};
|
||||
|
||||
display_device::Logger::get().setLogLevel(log_level);
|
||||
display_device::Logger::get().setCustomCallback([](const display_device::Logger::LogLevel level, const std::string &message) {
|
||||
@@ -192,15 +183,13 @@ namespace logging {
|
||||
});
|
||||
}
|
||||
|
||||
void
|
||||
log_flush() {
|
||||
void log_flush() {
|
||||
if (sink) {
|
||||
sink->flush();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
print_help(const char *name) {
|
||||
void print_help(const char *name) {
|
||||
std::cout
|
||||
<< "Usage: "sv << name << " [options] [/path/to/configuration_file] [--cmd]"sv << std::endl
|
||||
<< " Any configurable option can be overwritten with: \"name=value\""sv << std::endl
|
||||
@@ -220,13 +209,11 @@ namespace logging {
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
std::string
|
||||
bracket(const std::string &input) {
|
||||
std::string bracket(const std::string &input) {
|
||||
return "["s + input + "]"s;
|
||||
}
|
||||
|
||||
std::wstring
|
||||
bracket(const std::wstring &input) {
|
||||
std::wstring bracket(const std::wstring &input) {
|
||||
return L"["s + input + L"]"s;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user