From: Mikko Rasa Date: Wed, 21 Dec 2022 10:26:15 +0000 (+0200) Subject: Refactor logger to do message formatting internally X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=5e00719d0c63e306786ff36df61797cdbc86f3e9;p=builder.git Refactor logger to do message formatting internally This shortens the syntax of using it and may also provide a minor performance improvement since formatting doesn't need to be done for disabled channels. --- diff --git a/source/androidcompiler.cpp b/source/androidcompiler.cpp index 68c4e56..9ae31ac 100644 --- a/source/androidcompiler.cpp +++ b/source/androidcompiler.cpp @@ -68,7 +68,7 @@ void AndroidCompiler::do_prepare() build_info.incpath.push_back(public_dir); FS::Path arch_path = libstdcxx_path/"libs"; - builder.get_logger().log("files", format("Traversing %s", arch_path.str())); + builder.get_logger().log("files", "Traversing %s", arch_path.str()); string arch_dir = architecture->best_match(list_files(arch_path)); if(!arch_dir.empty()) { diff --git a/source/androidtools.cpp b/source/androidtools.cpp index 1633b8b..c5aab65 100644 --- a/source/androidtools.cpp +++ b/source/androidtools.cpp @@ -44,7 +44,7 @@ AndroidDevKit::AndroidDevKit(Builder &b, const string &type, const FS::Path &def root = default_path; else { - builder.get_logger().log("problems", format("Android %s not found", type)); + builder.get_logger().log("problems", "Android %s not found", type); return; } } @@ -53,13 +53,13 @@ AndroidDevKit::AndroidDevKit(Builder &b, const string &type, const FS::Path &def if(!FS::exists(platforms_dir)) return; - builder.get_logger().log("files", format("Traversing %s", platforms_dir.str())); + builder.get_logger().log("files", "Traversing %s", platforms_dir.str()); supported_api_levels = 0; for(const string &p: list_filtered(platforms_dir, "^android-[1-9][0-9]*$")) { unsigned api = lexical_cast(p.substr(8)); if(api>63) - builder.get_logger().log("problems", format("API level %d is too high", api)); + builder.get_logger().log("problems", "API level %d is too high", api); else supported_api_levels |= 1< platform_archs = list_filtered(platform_archs_dir, "^arch-"); for(string &a: platform_archs) a.erase(0, 5); @@ -219,7 +219,7 @@ void AndroidNdk::init_api_level(unsigned api) } platform_sysroot = platform_archs_dir/("arch-"+use_arch); - builder.get_logger().log("tools", format("Android NDK platform sysroot is %s", platform_sysroot)); + builder.get_logger().log("tools", "Android NDK platform sysroot is %s", platform_sysroot); } @@ -232,7 +232,7 @@ AndroidTools::AndroidTools(Builder &builder, const Architecture &arch): unsigned api = 0; for(unsigned i=32; i>0; i>>=1) api += i*!!(common_api_levels>>(api+i)); - builder.get_logger().log("tools", format("Using Android API level %d", api)); + builder.get_logger().log("tools", "Using Android API level %d", api); sdk.select_api_level(api); ndk.select_api_level(api); } diff --git a/source/binarypackage.cpp b/source/binarypackage.cpp index 66d1225..adfca1a 100644 --- a/source/binarypackage.cpp +++ b/source/binarypackage.cpp @@ -105,7 +105,7 @@ void BinaryPackage::do_prepare() if(all_found) { base_path = prefix; - builder.get_logger().log("configure", format("%s found in %s", name, ((system && use_pkgconfig) ? "system" : base_path.str()))); + builder.get_logger().log("configure", "%s found in %s", name, ((system && use_pkgconfig) ? "system" : base_path.str())); break; } } @@ -113,7 +113,7 @@ void BinaryPackage::do_prepare() if(base_path.empty()) { // TODO report which files were not found - builder.get_logger().log("problems", format("Cannot locate files for %s", name)); + builder.get_logger().log("problems", "Cannot locate files for %s", name); problems.push_back("Cannot locate files"); return; } diff --git a/source/builder.cpp b/source/builder.cpp index 1b8ed3c..2392581 100644 --- a/source/builder.cpp +++ b/source/builder.cpp @@ -160,7 +160,7 @@ void Builder::load_build_file(const FS::Path &fn, const Config::InputOptions *op { IO::BufferedFile in(fn.str()); - get_logger().log("files", format("Reading %s", fn)); + get_logger().log("files", "Reading %s", fn); DataFile::Parser parser(in, fn.str()); Loader loader(*this, opts, all); @@ -182,7 +182,7 @@ int Builder::build(unsigned jobs, bool dry_run, bool show_progress) get_logger().log("summary", "Already up to date"); return 0; } - get_logger().log("summary", format("Will build %d target%s", total, (total!=1 ? "s" : ""))); + get_logger().log("summary", "Will build %d target%s", total, (total!=1 ? "s" : "")); vector tasks; @@ -200,11 +200,11 @@ int Builder::build(unsigned jobs, bool dry_run, bool show_progress) if(tgt) { if(tgt->get_tool()) - get_logger().log("tasks", format("%-4s %s", tgt->get_tool()->get_tag(), tgt->get_name())); + get_logger().log("tasks", "%-4s %s", tgt->get_tool()->get_tag(), tgt->get_name()); Task *task = tgt->build(); if(task) { - get_logger().log("commands", format("%s", task->get_command())); + get_logger().log("commands", "%s", task->get_command()); if(dry_run) { task->signal_finished.emit(true); @@ -286,7 +286,7 @@ int Builder::clean(bool all, bool dry_run) for(Target *t: clean_tgts) { - get_logger().log("tasks", format("RM %s", t->get_name())); + get_logger().log("tasks", "RM %s", t->get_name()); if(!dry_run) t->clean(); } diff --git a/source/buildercli.cpp b/source/buildercli.cpp index 2469f51..41a2429 100644 --- a/source/buildercli.cpp +++ b/source/buildercli.cpp @@ -205,16 +205,16 @@ int BuilderCLI::main() const Architecture &native_arch = builder.get_native_arch(); const Architecture ¤t_arch = builder.get_current_arch(); - logger.log("environment", format("Building on %s, for %s%s", native_arch.get_name(), - current_arch.get_name(), (current_arch.is_native() ? " (native)" : ""))); - logger.log("environment", format("Prefix is %s", builder.get_prefix())); + logger.log("environment", "Building on %s, for %s%s", native_arch.get_name(), + current_arch.get_name(), (current_arch.is_native() ? " (native)" : "")); + logger.log("environment", "Prefix is %s", builder.get_prefix()); const FS::Path &tempdir = builder.get_temp_directory(); if(tempdir.is_absolute()) - logger.log("environment", format("Temporary directory is %s", tempdir)); + logger.log("environment", "Temporary directory is %s", tempdir); else - logger.log("environment", format("Using per-package temporary directory %s", tempdir)); + logger.log("environment", "Using per-package temporary directory %s", tempdir); const BuildType &build_type = builder.get_build_type(); - logger.log("environment", format("Build type is %s", build_type.get_name())); + logger.log("environment", "Build type is %s", build_type.get_name()); if(!prepare_build()) return 1; @@ -256,7 +256,7 @@ int BuilderCLI::main() package_details.push_back(line); } - logger.log("summary", format("%d active packages, %d targets", package_details.size(), build_graph.get_targets().size())); + logger.log("summary", "%d active packages, %d targets", package_details.size(), build_graph.get_targets().size()); for(const string &d: package_details) logger.log("packages", d); diff --git a/source/cache.cpp b/source/cache.cpp index 229783a..30f3fc3 100644 --- a/source/cache.cpp +++ b/source/cache.cpp @@ -78,14 +78,14 @@ void Cache::append_value(const Target *tgt, const string &k, const string &v) i = data.insert({ key, Values() }).first; i->second.push_back(v); changed = true; - package.get_builder().get_logger().log("cache", format("Updated key %s %s+ %s", tgt->get_name(), k, v)); + package.get_builder().get_logger().log("cache", "Updated key %s %s+ %s", tgt->get_name(), k, v); } void Cache::set_values(const Target *tgt, const string &k, const Values &v) { data[Key(tgt->get_name(), k)] = v; changed = true; - package.get_builder().get_logger().log("cache", format("Updated key %s %s: %s", tgt->get_name(), k, join(v.begin(), v.end()))); + package.get_builder().get_logger().log("cache", "Updated key %s %s: %s", tgt->get_name(), k, join(v.begin(), v.end())); } const string &Cache::get_value(const Target *tgt, const string &k) @@ -110,7 +110,7 @@ void Cache::load() { if(FS::Stat st = FS::stat(filename)) { - package.get_builder().get_logger().log("files", format("Reading %s", filename)); + package.get_builder().get_logger().log("files", "Reading %s", filename); IO::BufferedFile in(filename.str()); while(!in.eof()) @@ -123,7 +123,7 @@ void Cache::load() Values &values = data[key]; for(unsigned count = read_count(in); count; --count) values.push_back(read_string(in)); - package.get_builder().get_logger().log("cache", format("Loaded key %s %s: %s", key.first, key.second, join(values.begin(), values.end()))); + package.get_builder().get_logger().log("cache", "Loaded key %s %s: %s", key.first, key.second, join(values.begin(), values.end())); } mtime = st.get_modify_time(); @@ -138,7 +138,7 @@ void Cache::save() const FS::Path dir = FS::dirname(filename); if(!FS::exists(dir)) FS::mkpath(dir, 0755); - package.get_builder().get_logger().log("files", format("Writing %s", filename)); + package.get_builder().get_logger().log("files", "Writing %s", filename); IO::BufferedFile out(filename.str(), IO::M_WRITE); for(const auto &kvp: data) diff --git a/source/component.cpp b/source/component.cpp index a571933..e3f80fb 100644 --- a/source/component.cpp +++ b/source/component.cpp @@ -113,7 +113,7 @@ vector Component::collect_source_files() const set overlay_files; for(auto j=dirs.begin(); j!=dirs.end(); ++j) { - package.get_builder().get_logger().log("files", format("Traversing %s", *j)); + package.get_builder().get_logger().log("files", "Traversing %s", *j); for(const string &f: list_files(*j)) { if(j!=dirs.begin()) diff --git a/source/conditionalloader.cpp b/source/conditionalloader.cpp index 6233435..b9d9d25 100644 --- a/source/conditionalloader.cpp +++ b/source/conditionalloader.cpp @@ -1,4 +1,3 @@ -#include #include "booleanevaluator.h" #include "builder.h" #include "conditionalloader.h" @@ -19,7 +18,7 @@ void ArchitectureConditional::if_arch(const string &cond) const Architecture &arch = builder.get_current_arch(); BooleanEvaluator eval([&arch](const string &value){ return arch.match_name(value); }); bool match = eval.evaluate(cond); - builder.get_logger().log("configure", format("%s: arch %s %smatched", log_prefix, cond, (match ? "" : "not "))); + builder.get_logger().log("configure", "%s: arch %s %smatched", log_prefix, cond, (match ? "" : "not ")); if(match) load_sub_with(*this); } @@ -36,7 +35,7 @@ void FeatureConditional::if_feature(const string &cond) { BooleanEvaluator eval([this](const string &feat, const string *value){ return package.match_feature(feat, value); }); bool match = eval.evaluate(cond); - package.get_builder().get_logger().log("configure", format("%s: feature %s %smatched", log_prefix, cond, (match ? "" : "not "))); + package.get_builder().get_logger().log("configure", "%s: feature %s %smatched", log_prefix, cond, (match ? "" : "not ")); if(match) load_sub_with(*this); } diff --git a/source/config.cpp b/source/config.cpp index 4e57fdf..74d582e 100644 --- a/source/config.cpp +++ b/source/config.cpp @@ -62,7 +62,7 @@ void Config::load() FS::Stat stat = FS::stat(fn); if(stat) { - package.get_builder().get_logger().log("files", format("Reading %s", fn)); + package.get_builder().get_logger().log("files", "Reading %s", fn); IO::BufferedFile in(fn.str()); mtime = stat.get_modify_time(); @@ -80,7 +80,7 @@ void Config::save() const FS::Path fn = package.get_source_directory()/".config"; - package.get_builder().get_logger().log("files", format("Writing %s", fn)); + package.get_builder().get_logger().log("files", "Writing %s", fn); IO::BufferedFile out(fn.str(), IO::M_WRITE); DataFile::Writer writer(out); diff --git a/source/csourcefile.cpp b/source/csourcefile.cpp index e9b0bc8..6429d4f 100644 --- a/source/csourcefile.cpp +++ b/source/csourcefile.cpp @@ -47,7 +47,7 @@ void CSourceFile::find_dependencies() { IO::BufferedFile in(path.str()); - builder.get_logger().log("files", format("Reading includes from %s", path.str())); + builder.get_logger().log("files", "Reading includes from %s", path.str()); parse_includes(in); cache.set_values(this, "includes", includes); diff --git a/source/datatransform.cpp b/source/datatransform.cpp index 055587a..01d237b 100644 --- a/source/datatransform.cpp +++ b/source/datatransform.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #include #include "builder.h" #include "cache.h" @@ -31,7 +30,7 @@ void DataTransform::find_dependencies() files = cache.get_values(this, "files"); else { - builder.get_logger().log("files", format("Reading imports from %s", path.str())); + builder.get_logger().log("files", "Reading imports from %s", path.str()); IO::File in(path.str()); DataFile::Parser parser(in, path.str()); @@ -45,7 +44,7 @@ void DataTransform::find_dependencies() if(dir_files.empty()) { FS::Path dir = FS::dirname(path); - builder.get_logger().log("files", format("Traversing %s", dir.str())); + builder.get_logger().log("files", "Traversing %s", dir.str()); dir_files = list_files(dir); } diff --git a/source/gnucompiler.cpp b/source/gnucompiler.cpp index 9e7eb39..b8b2515 100644 --- a/source/gnucompiler.cpp +++ b/source/gnucompiler.cpp @@ -126,7 +126,7 @@ void GnuCompiler::prepare_syspath() argv.push_back("--sysroot="+sysroot.str()); argv.push_back("-"); - builder.get_logger().log("auxcommands", format("Running %s", join(argv.begin(), argv.end()))); + builder.get_logger().log("auxcommands", "Running %s", join(argv.begin(), argv.end())); try { string output = ExternalTask::run_and_capture_output(argv, FS::Path(), true); @@ -145,7 +145,7 @@ void GnuCompiler::prepare_syspath() else if(record_path) { FS::Path path = strip(output.substr(start, newline-start)); - builder.get_logger().log("tools", format("Got %s system path: %s", tag, path)); + builder.get_logger().log("tools", "Got %s system path: %s", tag, path); system_path.push_back(path); } start = newline+1; @@ -157,7 +157,7 @@ void GnuCompiler::prepare_syspath() if(!path_found) { - builder.get_logger().log("tools", format("No %s system path found, using defaults", tag)); + builder.get_logger().log("tools", "No %s system path found, using defaults", tag); if(!sysroot.empty()) system_path.push_back(sysroot/"usr/include"); else if(architecture->is_native()) @@ -175,7 +175,7 @@ void GnuCompiler::prepare_version() prepare_version("-dumpversion"); if(version>=0x70000) prepare_version("-dumpfullversion"); - builder.get_logger().log("tools", format("%s version is %d.%d.%d", FS::basename(executable->get_path()), version>>16, (version>>8)&0xFF, version&0xFF)); + builder.get_logger().log("tools", "%s version is %d.%d.%d", FS::basename(executable->get_path()), version>>16, (version>>8)&0xFF, version&0xFF); } void GnuCompiler::prepare_version(const string &arg) @@ -184,7 +184,7 @@ void GnuCompiler::prepare_version(const string &arg) argv.push_back(executable->get_path().str()); argv.push_back(arg); - builder.get_logger().log("auxcommands", format("Running %s", join(argv.begin(), argv.end()))); + builder.get_logger().log("auxcommands", "Running %s", join(argv.begin(), argv.end())); try { string version_str = strip(ExternalTask::run_and_capture_output(argv)); diff --git a/source/gnulinker.cpp b/source/gnulinker.cpp index 72c8b07..56becc2 100644 --- a/source/gnulinker.cpp +++ b/source/gnulinker.cpp @@ -111,7 +111,7 @@ void GnuLinker::do_prepare() if(!sysroot.empty()) argv.push_back("--sysroot="+sysroot.str()); - builder.get_logger().log("auxcommands", format("Running %s", join(argv.begin(), argv.end()))); + builder.get_logger().log("auxcommands", "Running %s", join(argv.begin(), argv.end())); try { string output = ExternalTask::run_and_capture_output(argv, FS::Path(), true); @@ -138,7 +138,7 @@ void GnuLinker::do_prepare() } path /= output.substr(search_dir, end-search_dir); - builder.get_logger().log("tools", format("Got %s system path: %s", tag, path)); + builder.get_logger().log("tools", "Got %s system path: %s", tag, path); system_path.push_back(path); path_found = true; @@ -152,7 +152,7 @@ void GnuLinker::do_prepare() if(!path_found) { - builder.get_logger().log("tools", format("No %s system path found, using defaults", tag)); + builder.get_logger().log("tools", "No %s system path found, using defaults", tag); if(!sysroot.empty()) system_path.push_back(sysroot/"usr/lib"); else if(architecture->is_native()) diff --git a/source/logger.cpp b/source/logger.cpp index dfb5fd4..35d4507 100644 --- a/source/logger.cpp +++ b/source/logger.cpp @@ -19,9 +19,19 @@ void Logger::disable_channel(const string &chan) enabled_channels.erase(i); } -void Logger::log(const string &chan, const string &message) const +bool Logger::is_channel_enabled(const string &chan) const { auto i = lower_bound(enabled_channels, chan); - if(i!=enabled_channels.end() && *i==chan) - IO::print("%s\n", message); + return (i!=enabled_channels.end() && *i==chan); +} + +void Logger::log(const string &chan, const string &message) const +{ + if(is_channel_enabled(chan)) + print(message); +} + +void Logger::print(const string &message) const +{ + IO::print("%s\n", message); } diff --git a/source/logger.h b/source/logger.h index 64c1315..3a10f0e 100644 --- a/source/logger.h +++ b/source/logger.h @@ -3,6 +3,7 @@ #include #include +#include class Logger { @@ -12,8 +13,22 @@ private: public: void enable_channel(const std::string &); void disable_channel(const std::string &); + bool is_channel_enabled(const std::string &) const; void log(const std::string &, const std::string &) const; + + template + void log(const std::string &, const std::string &, Args &&...) const; + +private: + void print(const std::string &) const; }; +template +void Logger::log(const std::string &chan, const std::string &fmt, Args &&... args) const +{ + if(is_channel_enabled(chan)) + print(Msp::format(fmt, std::forward(args)...)); +} + #endif diff --git a/source/microsofttools.cpp b/source/microsofttools.cpp index 9d3f1da..d6ed9e4 100644 --- a/source/microsofttools.cpp +++ b/source/microsofttools.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include "builder.h" #include "externaltask.h" @@ -35,15 +34,15 @@ void MicrosoftTools::find_vc_bin_dir(Builder &builder, const Architecture &arch) argv.push_back("-property"); argv.push_back("installationPath"); - builder.get_logger().log("auxcommands", format("Running %s", join(argv.begin(), argv.end()))); + builder.get_logger().log("auxcommands", "Running %s", join(argv.begin(), argv.end())); string output = ExternalTask::run_and_capture_output(argv, FS::Path(), true); FS::Path vs_path = strip(output); - builder.get_logger().log("tools", format("Visual Studio found in %s", vs_path)); + builder.get_logger().log("tools", "Visual Studio found in %s", vs_path); FS::Path vc_aux_build_dir = vs_path/"VC"/"Auxiliary"/"Build"; - builder.get_logger().log("files", format("Traversing %s", vc_aux_build_dir)); + builder.get_logger().log("files", "Traversing %s", vc_aux_build_dir); vector vc_version_files = FS::list_filtered(vc_aux_build_dir, "^Microsoft\\.VCToolsVersion\\."); if(vc_version_files.empty()) { @@ -53,12 +52,12 @@ void MicrosoftTools::find_vc_bin_dir(Builder &builder, const Architecture &arch) sort(vc_version_files); FS::Path vc_version_fn = vc_aux_build_dir/vc_version_files.back(); - builder.get_logger().log("files", format("Reading %s", vc_version_fn)); + builder.get_logger().log("files", "Reading %s", vc_version_fn); char buffer[256]; unsigned len = IO::File(vc_version_fn.str()).read(buffer, sizeof(buffer)); string vc_version = strip(string(buffer, len)); - builder.get_logger().log("tools", format("Detected MSVC version %s", vc_version)); + builder.get_logger().log("tools", "Detected MSVC version %s", vc_version); const Architecture &native_arch = builder.get_native_arch(); string host = (native_arch.get_bits()==64 ? "Hostx64" : "Hostx86"); @@ -74,7 +73,7 @@ void MicrosoftTools::find_windows_sdk_dir(Builder &builder) if(win_sdk_dir.empty()) win_sdk_dir = get_program_files_x86_dir()/"Windows Kits"/"10"; - builder.get_logger().log("files", format("Traversing %s", win_sdk_dir/"include")); + builder.get_logger().log("files", "Traversing %s", win_sdk_dir/"include"); vector sdk_versions = FS::list_filtered(win_sdk_dir/"include", "^10\\."); if(sdk_versions.empty()) { @@ -85,5 +84,5 @@ void MicrosoftTools::find_windows_sdk_dir(Builder &builder) sort(sdk_versions); win_sdk_version = sdk_versions.back(); - builder.get_logger().log("tools", format("Windows SDK version %s found in %s", win_sdk_version, win_sdk_dir)); + builder.get_logger().log("tools", "Windows SDK version %s found in %s", win_sdk_version, win_sdk_dir); } diff --git a/source/msvccompiler.cpp b/source/msvccompiler.cpp index c406627..dbbc64d 100644 --- a/source/msvccompiler.cpp +++ b/source/msvccompiler.cpp @@ -87,7 +87,7 @@ void MsvcCompiler::do_prepare() for(const FS::Path &p: system_path) { append(path, ";", p.str()); - builder.get_logger().log("tools", format("Got %s system path: %s", tag, p)); + builder.get_logger().log("tools", "Got %s system path: %s", tag, p); } setenv("INCLUDE", path); diff --git a/source/msvclinker.cpp b/source/msvclinker.cpp index f6d514b..78cf0b2 100644 --- a/source/msvclinker.cpp +++ b/source/msvclinker.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include "builder.h" #include "component.h" @@ -79,7 +78,7 @@ void MsvcLinker::do_prepare() for(const FS::Path &p: system_path) { append(path, ";", p.str()); - builder.get_logger().log("tools", format("Got %s system path: %s", tag, p)); + builder.get_logger().log("tools", "Got %s system path: %s", tag, p); } setenv("LIB", path); diff --git a/source/packagemanager.cpp b/source/packagemanager.cpp index af672d9..31b2461 100644 --- a/source/packagemanager.cpp +++ b/source/packagemanager.cpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include @@ -162,7 +161,7 @@ string PackageManager::run_pkgconfig(const string &pkg, const string &what) argv.push_back("--variable="+what); argv.push_back(pkg); - builder.get_logger().log("auxcommands", format("Running %s", join(argv.begin(), argv.end()))); + builder.get_logger().log("auxcommands", "Running %s", join(argv.begin(), argv.end())); return ExternalTask::run_and_capture_output(argv); #else @@ -174,7 +173,7 @@ string PackageManager::run_pkgconfig(const string &pkg, const string &what) FS::Path PackageManager::get_package_location(const string &name) { - builder.get_logger().log("packagemgr", format("Looking for source package %s", name)); + builder.get_logger().log("packagemgr", "Looking for source package %s", name); try { @@ -190,7 +189,7 @@ FS::Path PackageManager::get_package_location(const string &name) { for(const FS::Path &p: pkg_path) { - builder.get_logger().log("files", format("Traversing %s", p)); + builder.get_logger().log("files", "Traversing %s", p); unsigned count = 0; for(const string &f: list_files(p)) { @@ -202,10 +201,10 @@ FS::Path PackageManager::get_package_location(const string &name) } } - builder.get_logger().log("packagemgr", format("%d source packages found in %s", count, p)); + builder.get_logger().log("packagemgr", "%d source packages found in %s", count, p); } - builder.get_logger().log("packagemgr", format("%d source packages found", pkg_dirs.size())); + builder.get_logger().log("packagemgr", "%d source packages found", pkg_dirs.size()); } bool msp = !name.compare(0, 3, "msp"); @@ -225,20 +224,20 @@ FS::Path PackageManager::get_package_location(const string &name) FS::Path PackageManager::get_binary_package_file(const string &name) { - builder.get_logger().log("packagemgr", format("Looking for binary package %s", name)); + builder.get_logger().log("packagemgr", "Looking for binary package %s", name); if(binpkg_files.empty()) { for(const FS::Path &p: binpkg_path) { - builder.get_logger().log("files", format("Traversing %s", p)); + builder.get_logger().log("files", "Traversing %s", p); vector files = list_filtered(p, "\\.bpk$"); for(const string &f: files) binpkg_files.push_back(p/f); - builder.get_logger().log("packagemgr", format("%d binary packages found in %s", files.size(), p)); + builder.get_logger().log("packagemgr", "%d binary packages found in %s", files.size(), p); } - builder.get_logger().log("packagemgr", format("%d binary packages found", binpkg_files.size())); + builder.get_logger().log("packagemgr", "%d binary packages found", binpkg_files.size()); } auto i = find_if(binpkg_files, [&name](const FS::Path &p){ return FS::basepart(FS::basename(p))==name; }); diff --git a/source/target.cpp b/source/target.cpp index d21bda8..055abb5 100644 --- a/source/target.cpp +++ b/source/target.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #include "builder.h" #include "filetarget.h" #include "sourcepackage.h" @@ -110,7 +109,7 @@ void Target::mark_rebuild(const string &reason) state = REBUILD; rebuild_reason = reason; - builder.get_logger().log("rebuild", format("Rebuilding %s: %s", name, reason)); + builder.get_logger().log("rebuild", "Rebuilding %s: %s", name, reason); signal_bubble_rebuild.emit(); } @@ -121,7 +120,7 @@ void Target::prepare() return; if(state==PREPARING) { - builder.get_logger().log("problems", format("Dependency cycle detected at %s", name)); + builder.get_logger().log("problems", "Dependency cycle detected at %s", name); problems.push_back("Dependency cycle detected"); state = BROKEN; return; diff --git a/source/tool.cpp b/source/tool.cpp index 5413821..da7054a 100644 --- a/source/tool.cpp +++ b/source/tool.cpp @@ -62,7 +62,7 @@ void Tool::prepare() executable = builder.get_vfs().find_binary(command); if(!executable) { - builder.get_logger().log("problems", format("Can't find executable %s for %s", command, tag)); + builder.get_logger().log("problems", "Can't find executable %s for %s", command, tag); problems.push_back(format("Can't find executable %s", command)); } } diff --git a/source/virtualfilesystem.cpp b/source/virtualfilesystem.cpp index 2fecdf0..d3bc708 100644 --- a/source/virtualfilesystem.cpp +++ b/source/virtualfilesystem.cpp @@ -32,7 +32,7 @@ void VirtualFileSystem::register_path(const FS::Path &path, FileTarget *t) { targets.insert({ path, t }); nonexistent.erase(path); - builder.get_logger().log("vfs", format("Path %s registered to %s", path, t->get_name())); + builder.get_logger().log("vfs", "Path %s registered to %s", path, t->get_name()); } FileTarget *VirtualFileSystem::find_header(const string &name, Tool *tool, const SearchPath &path, bool use_syspath) @@ -56,16 +56,16 @@ FileTarget *VirtualFileSystem::find_header(const string &name, Tool *tool, const FS::Path filename = p/name; if(FileTarget *tgt = get_target(filename)) { - builder.get_logger().log("vfs", format("Header %s found in %s as existing %s", name, p.str(), tgt->get_type())); + builder.get_logger().log("vfs", "Header %s found in %s as existing %s", name, p.str(), tgt->get_type()); return tgt; } else if(file_exists(filename)) { - builder.get_logger().log("vfs", format("Header %s found in %s", name, p.str())); + builder.get_logger().log("vfs", "Header %s found in %s", name, p.str()); return dynamic_cast(tool->create_source(filename)); } - builder.get_logger().log("vfs", format("Header %s not found in %s", name, p.str())); + builder.get_logger().log("vfs", "Header %s not found in %s", name, p.str()); } return 0; @@ -105,12 +105,12 @@ FileTarget *VirtualFileSystem::find_library(const string &lib, const SearchPath FS::Path filename = p / *j; if(FileTarget *tgt = get_target(filename)) { - builder.get_logger().log("vfs", format("Library %s (%s) found in %s as existing %s", lib, *j, p.str(), tgt->get_type())); + builder.get_logger().log("vfs", "Library %s (%s) found in %s as existing %s", lib, *j, p.str(), tgt->get_type()); return tgt; } else if(file_exists(filename)) { - builder.get_logger().log("vfs", format("Library %s (%s) found in %s", lib, *j, p.str())); + builder.get_logger().log("vfs", "Library %s (%s) found in %s", lib, *j, p.str()); if(cur_names==&shared_names) { if(use_import_lib) @@ -133,7 +133,7 @@ FileTarget *VirtualFileSystem::find_library(const string &lib, const SearchPath } } - builder.get_logger().log("vfs", format("Library %s not found in %s", lib, p.str())); + builder.get_logger().log("vfs", "Library %s not found in %s", lib, p.str()); } return 0; @@ -168,16 +168,16 @@ FileTarget *VirtualFileSystem::find_binary(const string &name) FS::Path filename = p/name; if(FileTarget *tgt = get_target(filename)) { - builder.get_logger().log("vfs", format("Binary %s found in %s as existing %s", name, p, tgt->get_type())); + builder.get_logger().log("vfs", "Binary %s found in %s as existing %s", name, p, tgt->get_type()); return tgt; } else if(file_exists(filename)) { - builder.get_logger().log("vfs", format("Binary %s found in %s", name, p)); + builder.get_logger().log("vfs", "Binary %s found in %s", name, p); return new Executable(builder, filename); } - builder.get_logger().log("vfs", format("Binary %s not found in %s", name, p)); + builder.get_logger().log("vfs", "Binary %s not found in %s", name, p); } return 0;