Replace most uses of std::cerr with util::dprint

This commit is contained in:
2023-04-07 16:00:52 -04:00
parent 9d593cc767
commit ef7d0ec365
8 changed files with 7 additions and 22 deletions

View File

@@ -5,7 +5,6 @@
#include <string_view> #include <string_view>
#include <utility> #include <utility>
#include <iostream>
#include <cstring> #include <cstring>
#include <cstdio> #include <cstdio>
#include <fstream> #include <fstream>

View File

@@ -1,5 +1,4 @@
#include "luastack.hpp" #include "luastack.hpp"
#include <iostream>
#include <cassert> #include <cassert>
#include <cstdio> #include <cstdio>
#include <climits> #include <climits>

View File

@@ -4,7 +4,6 @@
#include "util.hpp" #include "util.hpp"
#include "table.hpp" #include "table.hpp"
#include <iostream>
#include <cmath> #include <cmath>
class PrintMachine { class PrintMachine {

View File

@@ -16,7 +16,6 @@
#include <algorithm> #include <algorithm>
#include <fstream> #include <fstream>
#include <iostream>
LuaDefine(makeclass, "classname", "create a class if it doesn't already exist") { LuaDefine(makeclass, "classname", "create a class if it doesn't already exist") {
LuaArg classname; LuaArg classname;
@@ -378,14 +377,14 @@ void SourceDB::run_unittests() {
// Run the functions in order // Run the functions in order
bool any = false; bool any = false;
for (const eng::string &name : names) { for (const eng::string &name : names) {
std::cerr << "Running unittests." << name << std::endl; util::dprint("Running unittests: ", name);
LS.rawget(func, unittests, name); LS.rawget(func, unittests, name);
lua_pushvalue(L, func.index()); lua_pushvalue(L, func.index());
eng::string msg = traceback_pcall(L, 0, 0); eng::string msg = traceback_pcall(L, 0, 0);
if (!msg.empty()) { if (!msg.empty()) {
LS.set(err, msg); LS.set(err, msg);
std::cerr << msg << std::endl; util::dprint(msg);
any = true; any = true;
} }
} }
@@ -500,7 +499,7 @@ void SourceDB::register_lua_builtins() {
if (reg->get_func() == nullptr) { if (reg->get_func() == nullptr) {
if (builtin == nullptr) { if (builtin == nullptr) {
if (!reg->get_sandbox()) { if (!reg->get_sandbox()) {
std::cerr << "No such builtin function: " << classname << " " << funcname << std::endl; util::dprint("No such builtin function: ", classname, " ", funcname);
} }
} else { } else {
reg->set_func(builtin); reg->set_func(builtin);
@@ -516,8 +515,7 @@ void SourceDB::register_lua_builtins() {
LS.set(lfuncname, LuaNil); LS.set(lfuncname, LuaNil);
while (LS.next(classtab, lfuncname, func)) { while (LS.next(classtab, lfuncname, func)) {
if (LS.iscfunction(func)) { if (LS.iscfunction(func)) {
std::cerr << "Failed to declare builtin: " << LS.ckstring(lclassname) << "." util::dprint("Failed to declare builtin: ", LS.ckstring(lclassname), ".", LS.ckstring(lfuncname));
<< LS.ckstring(lfuncname) << std::endl;
} }
} }
} }

View File

@@ -3,7 +3,6 @@
#include "pprint.hpp" #include "pprint.hpp"
#include "serializelua.hpp" #include "serializelua.hpp"
#include <cmath> #include <cmath>
#include <iostream>
static void tangible_getall(LuaCoreStack &LS0, LuaSlot list, const util::IdVector &idv) { static void tangible_getall(LuaCoreStack &LS0, LuaSlot list, const util::IdVector &idv) {
LuaVar tangibles, tan; LuaVar tangibles, tan;

View File

@@ -355,7 +355,7 @@ void World::update_gui(int64_t actor_id, int64_t place_id, Gui *gui) {
Gui::store_global_pointer(L, nullptr); Gui::store_global_pointer(L, nullptr);
if (!msg.empty()) { if (!msg.empty()) {
gui->clear(0); gui->clear(0);
std::cerr << msg << std::endl; util::dprint(msg);
LS.result(); LS.result();
return; return;
} }
@@ -376,10 +376,7 @@ void World::update_source(const util::LuaSourceVec &source) {
source_db_.update(source); source_db_.update(source);
assert(stack_is_clear()); assert(stack_is_clear());
eng::string errs = source_db_.rebuild(); eng::string errs = source_db_.rebuild();
// I don't have a good place to send the error messages right util::dprint(errs);
// now. The engine needs a catch-all place to send errors that
// occur at unexpected times.
std::cerr << errs;
assert(stack_is_clear()); assert(stack_is_clear());
} }
@@ -976,8 +973,6 @@ void World::serialize(StreamBuffer *sb) {
sb->write_int64(p.first); sb->write_int64(p.first);
p.second->serialize(sb); p.second->serialize(sb);
} }
// int64_t wc1 = sb->total_writes();
// std::cerr << "World serialized to " << wc1-wc0 << " bytes." << std::endl;
assert(stack_is_clear()); assert(stack_is_clear());
} }

View File

@@ -22,7 +22,6 @@
#include "streambuffer.hpp" #include "streambuffer.hpp"
#include "table.hpp" #include "table.hpp"
#include "world.hpp" #include "world.hpp"
#include <iostream>
// Given a table and an tnmap, return the table number of the table. // Given a table and an tnmap, return the table number of the table.
// Returns zero if the table doesn't have a table number. // Returns zero if the table doesn't have a table number.

View File

@@ -1,4 +1,3 @@
#include <iostream>
#include "world.hpp" #include "world.hpp"
@@ -294,9 +293,7 @@ void World::patch_source(StreamBuffer *sb, DebugCollector *dbc) {
if (modified) { if (modified) {
eng::string errs = source_db_.rebuild(); eng::string errs = source_db_.rebuild();
DebugLine(dbc) << "Source DB rebuilt"; DebugLine(dbc) << "Source DB rebuilt";
// TODO: I don't currently have any good place to send the util::dprint(errs);
// error messages. This is a stopgap.
std::cerr << errs;
} }
} }