From ef7d0ec365cba447500b408be6bc03c12150a2d0 Mon Sep 17 00:00:00 2001 From: jyelon Date: Fri, 7 Apr 2023 16:00:52 -0400 Subject: [PATCH] Replace most uses of std::cerr with util::dprint --- luprex/cpp/core/drivenengine.cpp | 1 - luprex/cpp/core/luastack.cpp | 1 - luprex/cpp/core/pprint.cpp | 1 - luprex/cpp/core/source.cpp | 10 ++++------ luprex/cpp/core/world-accessor.cpp | 1 - luprex/cpp/core/world-core.cpp | 9 ++------- luprex/cpp/core/world-difftab.cpp | 1 - luprex/cpp/core/world-diffxmit.cpp | 5 +---- 8 files changed, 7 insertions(+), 22 deletions(-) diff --git a/luprex/cpp/core/drivenengine.cpp b/luprex/cpp/core/drivenengine.cpp index 2ebbe43e..34aa1bf8 100644 --- a/luprex/cpp/core/drivenengine.cpp +++ b/luprex/cpp/core/drivenengine.cpp @@ -5,7 +5,6 @@ #include #include -#include #include #include #include diff --git a/luprex/cpp/core/luastack.cpp b/luprex/cpp/core/luastack.cpp index 08562033..3adf714f 100644 --- a/luprex/cpp/core/luastack.cpp +++ b/luprex/cpp/core/luastack.cpp @@ -1,5 +1,4 @@ #include "luastack.hpp" -#include #include #include #include diff --git a/luprex/cpp/core/pprint.cpp b/luprex/cpp/core/pprint.cpp index 57a2a340..2180633c 100644 --- a/luprex/cpp/core/pprint.cpp +++ b/luprex/cpp/core/pprint.cpp @@ -4,7 +4,6 @@ #include "util.hpp" #include "table.hpp" -#include #include class PrintMachine { diff --git a/luprex/cpp/core/source.cpp b/luprex/cpp/core/source.cpp index 0ebcfe72..7a940a48 100644 --- a/luprex/cpp/core/source.cpp +++ b/luprex/cpp/core/source.cpp @@ -16,7 +16,6 @@ #include #include -#include LuaDefine(makeclass, "classname", "create a class if it doesn't already exist") { LuaArg classname; @@ -378,14 +377,14 @@ void SourceDB::run_unittests() { // Run the functions in order bool any = false; for (const eng::string &name : names) { - std::cerr << "Running unittests." << name << std::endl; + util::dprint("Running unittests: ", name); LS.rawget(func, unittests, name); lua_pushvalue(L, func.index()); eng::string msg = traceback_pcall(L, 0, 0); if (!msg.empty()) { LS.set(err, msg); - std::cerr << msg << std::endl; + util::dprint(msg); any = true; } } @@ -500,7 +499,7 @@ void SourceDB::register_lua_builtins() { if (reg->get_func() == nullptr) { if (builtin == nullptr) { if (!reg->get_sandbox()) { - std::cerr << "No such builtin function: " << classname << " " << funcname << std::endl; + util::dprint("No such builtin function: ", classname, " ", funcname); } } else { reg->set_func(builtin); @@ -516,8 +515,7 @@ void SourceDB::register_lua_builtins() { LS.set(lfuncname, LuaNil); while (LS.next(classtab, lfuncname, func)) { if (LS.iscfunction(func)) { - std::cerr << "Failed to declare builtin: " << LS.ckstring(lclassname) << "." - << LS.ckstring(lfuncname) << std::endl; + util::dprint("Failed to declare builtin: ", LS.ckstring(lclassname), ".", LS.ckstring(lfuncname)); } } } diff --git a/luprex/cpp/core/world-accessor.cpp b/luprex/cpp/core/world-accessor.cpp index c987590a..6430d3f3 100644 --- a/luprex/cpp/core/world-accessor.cpp +++ b/luprex/cpp/core/world-accessor.cpp @@ -3,7 +3,6 @@ #include "pprint.hpp" #include "serializelua.hpp" #include -#include static void tangible_getall(LuaCoreStack &LS0, LuaSlot list, const util::IdVector &idv) { LuaVar tangibles, tan; diff --git a/luprex/cpp/core/world-core.cpp b/luprex/cpp/core/world-core.cpp index 87066479..2b467dfa 100644 --- a/luprex/cpp/core/world-core.cpp +++ b/luprex/cpp/core/world-core.cpp @@ -355,7 +355,7 @@ void World::update_gui(int64_t actor_id, int64_t place_id, Gui *gui) { Gui::store_global_pointer(L, nullptr); if (!msg.empty()) { gui->clear(0); - std::cerr << msg << std::endl; + util::dprint(msg); LS.result(); return; } @@ -376,10 +376,7 @@ void World::update_source(const util::LuaSourceVec &source) { source_db_.update(source); assert(stack_is_clear()); eng::string errs = source_db_.rebuild(); - // I don't have a good place to send the error messages right - // now. The engine needs a catch-all place to send errors that - // occur at unexpected times. - std::cerr << errs; + util::dprint(errs); assert(stack_is_clear()); } @@ -976,8 +973,6 @@ void World::serialize(StreamBuffer *sb) { sb->write_int64(p.first); p.second->serialize(sb); } - // int64_t wc1 = sb->total_writes(); - // std::cerr << "World serialized to " << wc1-wc0 << " bytes." << std::endl; assert(stack_is_clear()); } diff --git a/luprex/cpp/core/world-difftab.cpp b/luprex/cpp/core/world-difftab.cpp index 2aaf7bf1..4cb716e6 100644 --- a/luprex/cpp/core/world-difftab.cpp +++ b/luprex/cpp/core/world-difftab.cpp @@ -22,7 +22,6 @@ #include "streambuffer.hpp" #include "table.hpp" #include "world.hpp" -#include // Given a table and an tnmap, return the table number of the table. // Returns zero if the table doesn't have a table number. diff --git a/luprex/cpp/core/world-diffxmit.cpp b/luprex/cpp/core/world-diffxmit.cpp index 0eb145d6..ce2067d4 100644 --- a/luprex/cpp/core/world-diffxmit.cpp +++ b/luprex/cpp/core/world-diffxmit.cpp @@ -1,4 +1,3 @@ -#include #include "world.hpp" @@ -294,9 +293,7 @@ void World::patch_source(StreamBuffer *sb, DebugCollector *dbc) { if (modified) { eng::string errs = source_db_.rebuild(); DebugLine(dbc) << "Source DB rebuilt"; - // TODO: I don't currently have any good place to send the - // error messages. This is a stopgap. - std::cerr << errs; + util::dprint(errs); } }