Ver código fonte

No logging with -lsilent, and reduce compile by not pulling spdlog so eagerly

default_compile_flags
vector-of-bool 4 anos atrás
pai
commit
44c577e20b
3 arquivos alterados com 11 adições e 3 exclusões
  1. +1
    -3
      src/dds.main.cpp
  2. +7
    -0
      src/dds/util/log.cpp
  3. +3
    -0
      src/dds/util/log.hpp

+ 1
- 3
src/dds.main.cpp Ver arquivo

@@ -27,7 +27,6 @@
#include <range/v3/view/concat.hpp>
#include <range/v3/view/group_by.hpp>
#include <range/v3/view/transform.hpp>
#include <spdlog/spdlog.h>

#include <dds/3rd/args.hxx>

@@ -73,7 +72,6 @@ struct toolchain_flag : string_flag {
return std::move(*tc);
} else {
return dds::parse_toolchain_json5(dds::slurp_file(tc_path));
// return dds::parse_toolchain_dds(dds::slurp_file(tc_path));
}
}
};
@@ -1195,7 +1193,7 @@ struct cli_build_deps {
*/

int main_fn(const std::vector<std::string>& argv) {
spdlog::set_pattern("[%H:%M:%S] [%^%-5l%$] %v");
dds::log::init_logger();
args::ArgumentParser parser("DDS - The drop-dead-simple library manager");

cli_base cli{parser};

+ 7
- 0
src/dds/util/log.cpp Ver arquivo

@@ -18,6 +18,11 @@ static void set_utf8_output() {
}
#endif

void dds::log::init_logger() noexcept {
// spdlog::set_pattern("[%H:%M:%S] [%^%-5l%$] %v");
spdlog::set_pattern("[%^%-5l%$] %v");
}

void dds::log::log_print(dds::log::level l, std::string_view msg) noexcept {
static auto logger_inst = [] {
auto logger = spdlog::default_logger_raw();
@@ -40,6 +45,8 @@ void dds::log::log_print(dds::log::level l, std::string_view msg) noexcept {
return spdlog::level::err;
case level::critical:
return spdlog::level::critical;
case level::_silent:
return spdlog::level::off;
}
neo_assert_always(invariant, false, "Invalid log level", msg, int(l));
}();

+ 3
- 0
src/dds/util/log.hpp Ver arquivo

@@ -13,12 +13,15 @@ enum class level : int {
warn,
error,
critical,
_silent,
};

inline level current_log_level = level::info;

void log_print(level l, std::string_view s) noexcept;

void init_logger() noexcept;

template <typename T>
concept formattable = requires(const T item) {
fmt::format("{}", item);

Carregando…
Cancelar
Salvar