Browse Source

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

default_compile_flags
vector-of-bool 4 years ago
parent
commit
44c577e20b
3 changed files with 11 additions and 3 deletions
  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 View File

#include <range/v3/view/concat.hpp> #include <range/v3/view/concat.hpp>
#include <range/v3/view/group_by.hpp> #include <range/v3/view/group_by.hpp>
#include <range/v3/view/transform.hpp> #include <range/v3/view/transform.hpp>
#include <spdlog/spdlog.h>


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


return std::move(*tc); return std::move(*tc);
} else { } else {
return dds::parse_toolchain_json5(dds::slurp_file(tc_path)); return dds::parse_toolchain_json5(dds::slurp_file(tc_path));
// return dds::parse_toolchain_dds(dds::slurp_file(tc_path));
} }
} }
}; };
*/ */


int main_fn(const std::vector<std::string>& argv) { 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"); args::ArgumentParser parser("DDS - The drop-dead-simple library manager");


cli_base cli{parser}; cli_base cli{parser};

+ 7
- 0
src/dds/util/log.cpp View File

} }
#endif #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 { void dds::log::log_print(dds::log::level l, std::string_view msg) noexcept {
static auto logger_inst = [] { static auto logger_inst = [] {
auto logger = spdlog::default_logger_raw(); auto logger = spdlog::default_logger_raw();
return spdlog::level::err; return spdlog::level::err;
case level::critical: case level::critical:
return spdlog::level::critical; return spdlog::level::critical;
case level::_silent:
return spdlog::level::off;
} }
neo_assert_always(invariant, false, "Invalid log level", msg, int(l)); neo_assert_always(invariant, false, "Invalid log level", msg, int(l));
}(); }();

+ 3
- 0
src/dds/util/log.hpp View File

warn, warn,
error, error,
critical, critical,
_silent,
}; };


inline level current_log_level = level::info; inline level current_log_level = level::info;


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


void init_logger() noexcept;

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

Loading…
Cancel
Save