Skip to content

Commit

Permalink
Use warningstream for log messages with WARNING
Browse files Browse the repository at this point in the history
Remove DTIME macro and its uses, too
  • Loading branch information
ShadowNinja authored and kwolekr committed Oct 14, 2015
1 parent 2139d7d commit 96cc5b3
Show file tree
Hide file tree
Showing 26 changed files with 92 additions and 94 deletions.
2 changes: 1 addition & 1 deletion src/ban.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ BanManager::BanManager(const std::string &banfilepath):
} }
catch(SerializationError &e) catch(SerializationError &e)
{ {
infostream<<"WARNING: BanManager: creating " warningstream<<"BanManager: creating "
<<m_banfilepath<<std::endl; <<m_banfilepath<<std::endl;
} }
} }
Expand Down
2 changes: 1 addition & 1 deletion src/clientobject.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ ClientActiveObject* ClientActiveObject::create(ActiveObjectType type,
n = m_types.find(type); n = m_types.find(type);
if(n == m_types.end()) { if(n == m_types.end()) {
// If factory is not found, just return. // If factory is not found, just return.
dstream<<"WARNING: ClientActiveObject: No factory for type=" warningstream<<"ClientActiveObject: No factory for type="
<<(int)type<<std::endl; <<(int)type<<std::endl;
return NULL; return NULL;
} }
Expand Down
4 changes: 2 additions & 2 deletions src/collision.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
Calculate new velocity Calculate new velocity
*/ */
if( dtime > 0.5 ) { if( dtime > 0.5 ) {
infostream<<"collisionMoveSimple: WARNING: maximum step interval exceeded, lost movement details!"<<std::endl; warningstream<<"collisionMoveSimple: maximum step interval exceeded, lost movement details!"<<std::endl;
dtime = 0.5; dtime = 0.5;
} }
speed_f += accel_f * dtime; speed_f += accel_f * dtime;
Expand Down Expand Up @@ -388,7 +388,7 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
loopcount++; loopcount++;
if(loopcount >= 100) if(loopcount >= 100)
{ {
infostream<<"collisionMoveSimple: WARNING: Loop count exceeded, aborting to avoid infiniite loop"<<std::endl; warningstream<<"collisionMoveSimple: Loop count exceeded, aborting to avoid infiniite loop"<<std::endl;
dtime = 0; dtime = 0;
break; break;
} }
Expand Down
2 changes: 1 addition & 1 deletion src/content_cao.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ void ItemCAO::updateTexture()
} }
catch(SerializationError &e) catch(SerializationError &e)
{ {
infostream<<"WARNING: "<<__FUNCTION_NAME warningstream<<__FUNCTION_NAME
<<": error deSerializing itemstring \"" <<": error deSerializing itemstring \""
<<m_itemstring<<std::endl; <<m_itemstring<<std::endl;
} }
Expand Down
2 changes: 1 addition & 1 deletion src/content_nodemeta.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ void content_nodemeta_deserialize_legacy(std::istream &is,


if(meta->get(p) != NULL) if(meta->get(p) != NULL)
{ {
infostream<<"WARNING: "<<__FUNCTION_NAME<<": " warningstream<<__FUNCTION_NAME<<": "
<<"already set data at position" <<"already set data at position"
<<"("<<p.X<<","<<p.Y<<","<<p.Z<<"): Ignoring." <<"("<<p.X<<","<<p.Y<<","<<p.Z<<"): Ignoring."
<<std::endl; <<std::endl;
Expand Down
4 changes: 2 additions & 2 deletions src/database-leveldb.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ bool Database_LevelDB::saveBlock(const v3s16 &pos, const std::string &data)
leveldb::Status status = m_database->Put(leveldb::WriteOptions(), leveldb::Status status = m_database->Put(leveldb::WriteOptions(),
i64tos(getBlockAsInteger(pos)), data); i64tos(getBlockAsInteger(pos)), data);
if (!status.ok()) { if (!status.ok()) {
errorstream << "WARNING: saveBlock: LevelDB error saving block " warningstream << "saveBlock: LevelDB error saving block "
<< PP(pos) << ": " << status.ToString() << std::endl; << PP(pos) << ": " << status.ToString() << std::endl;
return false; return false;
} }
Expand All @@ -82,7 +82,7 @@ bool Database_LevelDB::deleteBlock(const v3s16 &pos)
leveldb::Status status = m_database->Delete(leveldb::WriteOptions(), leveldb::Status status = m_database->Delete(leveldb::WriteOptions(),
i64tos(getBlockAsInteger(pos))); i64tos(getBlockAsInteger(pos)));
if (!status.ok()) { if (!status.ok()) {
errorstream << "WARNING: deleteBlock: LevelDB error deleting block " warningstream << "deleteBlock: LevelDB error deleting block "
<< PP(pos) << ": " << status.ToString() << std::endl; << PP(pos) << ": " << status.ToString() << std::endl;
return false; return false;
} }
Expand Down
6 changes: 3 additions & 3 deletions src/database-redis.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ bool Database_Redis::saveBlock(const v3s16 &pos, const std::string &data)
redisReply *reply = static_cast<redisReply *>(redisCommand(ctx, "HSET %s %s %b", redisReply *reply = static_cast<redisReply *>(redisCommand(ctx, "HSET %s %s %b",
hash.c_str(), tmp.c_str(), data.c_str(), data.size())); hash.c_str(), tmp.c_str(), data.c_str(), data.size()));
if (!reply) { if (!reply) {
errorstream << "WARNING: saveBlock: redis command 'HSET' failed on " warningstream << "saveBlock: redis command 'HSET' failed on "
"block " << PP(pos) << ": " << ctx->errstr << std::endl; "block " << PP(pos) << ": " << ctx->errstr << std::endl;
freeReplyObject(reply); freeReplyObject(reply);
return false; return false;
} }


if (reply->type == REDIS_REPLY_ERROR) { if (reply->type == REDIS_REPLY_ERROR) {
errorstream << "WARNING: saveBlock: saving block " << PP(pos) warningstream << "saveBlock: saving block " << PP(pos)
<< " failed: " << reply->str << std::endl; << " failed: " << reply->str << std::endl;
freeReplyObject(reply); freeReplyObject(reply);
return false; return false;
Expand Down Expand Up @@ -150,7 +150,7 @@ bool Database_Redis::deleteBlock(const v3s16 &pos)
throw FileNotGoodException(std::string( throw FileNotGoodException(std::string(
"Redis command 'HDEL %s %s' failed: ") + ctx->errstr); "Redis command 'HDEL %s %s' failed: ") + ctx->errstr);
} else if (reply->type == REDIS_REPLY_ERROR) { } else if (reply->type == REDIS_REPLY_ERROR) {
errorstream << "WARNING: deleteBlock: deleting block " << PP(pos) warningstream << "deleteBlock: deleting block " << PP(pos)
<< " failed: " << reply->str << std::endl; << " failed: " << reply->str << std::endl;
freeReplyObject(reply); freeReplyObject(reply);
return false; return false;
Expand Down
2 changes: 1 addition & 1 deletion src/database-sqlite3.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ bool Database_SQLite3::deleteBlock(const v3s16 &pos)
sqlite3_reset(m_stmt_delete); sqlite3_reset(m_stmt_delete);


if (!good) { if (!good) {
errorstream << "WARNING: deleteBlock: Block failed to delete " warningstream << "deleteBlock: Block failed to delete "
<< PP(pos) << ": " << sqlite3_errmsg(m_database) << std::endl; << PP(pos) << ": " << sqlite3_errmsg(m_database) << std::endl;
} }
return good; return good;
Expand Down
2 changes: 0 additions & 2 deletions src/debug.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ __NORETURN extern void sanity_check_fn(


void debug_set_exception_handler(); void debug_set_exception_handler();


#define DTIME ""

/* /*
DebugStack DebugStack
*/ */
Expand Down
4 changes: 2 additions & 2 deletions src/environment.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1188,7 +1188,7 @@ void ServerEnvironment::step(float dtime)
u32 time_ms = timer.stop(true); u32 time_ms = timer.stop(true);
u32 max_time_ms = 200; u32 max_time_ms = 200;
if(time_ms > max_time_ms){ if(time_ms > max_time_ms){
infostream<<"WARNING: active block modifiers took " warningstream<<"active block modifiers took "
<<time_ms<<"ms (longer than " <<time_ms<<"ms (longer than "
<<max_time_ms<<"ms)"<<std::endl; <<max_time_ms<<"ms)"<<std::endl;
m_active_block_interval_overload_skip = (time_ms / max_time_ms) + 1; m_active_block_interval_overload_skip = (time_ms / max_time_ms) + 1;
Expand Down Expand Up @@ -1910,7 +1910,7 @@ void ServerEnvironment::deactivateFarObjects(bool force_delete)
// reason. Unsuccessful attempts have been made to find // reason. Unsuccessful attempts have been made to find
// said reason. // said reason.
if(id && block->m_static_objects.m_active.find(id) != block->m_static_objects.m_active.end()){ if(id && block->m_static_objects.m_active.find(id) != block->m_static_objects.m_active.end()){
infostream<<"ServerEnv: WARNING: Performing hack #83274" warningstream<<"ServerEnv: Performing hack #83274"
<<std::endl; <<std::endl;
block->m_static_objects.remove(id); block->m_static_objects.remove(id);
} }
Expand Down
35 changes: 17 additions & 18 deletions src/guiFormSpecMenu.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ void GUIFormSpecMenu::parseSize(parserData* data,std::string element)
void GUIFormSpecMenu::parseList(parserData* data,std::string element) void GUIFormSpecMenu::parseList(parserData* data,std::string element)
{ {
if (m_gamedef == 0) { if (m_gamedef == 0) {
errorstream<<"WARNING: invalid use of 'list' with m_gamedef==0"<<std::endl; warningstream<<"invalid use of 'list' with m_gamedef==0"<<std::endl;
return; return;
} }


Expand Down Expand Up @@ -345,7 +345,7 @@ void GUIFormSpecMenu::parseList(parserData* data,std::string element)
} }


if(!data->explicit_size) if(!data->explicit_size)
errorstream<<"WARNING: invalid use of list without a size[] element"<<std::endl; warningstream<<"invalid use of list without a size[] element"<<std::endl;
m_inventorylists.push_back(ListDrawSpec(loc, listname, pos, geom, start_i)); m_inventorylists.push_back(ListDrawSpec(loc, listname, pos, geom, start_i));
return; return;
} }
Expand Down Expand Up @@ -525,7 +525,7 @@ void GUIFormSpecMenu::parseImage(parserData* data,std::string element)
geom.Y = stof(v_geom[1]) * (float)imgsize.Y; geom.Y = stof(v_geom[1]) * (float)imgsize.Y;


if(!data->explicit_size) if(!data->explicit_size)
errorstream<<"WARNING: invalid use of image without a size[] element"<<std::endl; warningstream<<"invalid use of image without a size[] element"<<std::endl;
m_images.push_back(ImageDrawSpec(name, pos, geom)); m_images.push_back(ImageDrawSpec(name, pos, geom));
return; return;
} }
Expand All @@ -541,7 +541,7 @@ void GUIFormSpecMenu::parseImage(parserData* data,std::string element)
pos.Y += stof(v_pos[1]) * (float) spacing.Y; pos.Y += stof(v_pos[1]) * (float) spacing.Y;


if(!data->explicit_size) if(!data->explicit_size)
errorstream<<"WARNING: invalid use of image without a size[] element"<<std::endl; warningstream<<"invalid use of image without a size[] element"<<std::endl;
m_images.push_back(ImageDrawSpec(name, pos)); m_images.push_back(ImageDrawSpec(name, pos));
return; return;
} }
Expand Down Expand Up @@ -571,7 +571,7 @@ void GUIFormSpecMenu::parseItemImage(parserData* data,std::string element)
geom.Y = stof(v_geom[1]) * (float)imgsize.Y; geom.Y = stof(v_geom[1]) * (float)imgsize.Y;


if(!data->explicit_size) if(!data->explicit_size)
errorstream<<"WARNING: invalid use of item_image without a size[] element"<<std::endl; warningstream<<"invalid use of item_image without a size[] element"<<std::endl;
m_itemimages.push_back(ImageDrawSpec(name, pos, geom)); m_itemimages.push_back(ImageDrawSpec(name, pos, geom));
return; return;
} }
Expand Down Expand Up @@ -607,7 +607,7 @@ void GUIFormSpecMenu::parseButton(parserData* data,std::string element,
pos.X + geom.X, pos.Y + m_btn_height); pos.X + geom.X, pos.Y + m_btn_height);


if(!data->explicit_size) if(!data->explicit_size)
errorstream<<"WARNING: invalid use of button without a size[] element"<<std::endl; warningstream<<"invalid use of button without a size[] element"<<std::endl;


label = unescape_string(label); label = unescape_string(label);


Expand Down Expand Up @@ -666,7 +666,7 @@ void GUIFormSpecMenu::parseBackground(parserData* data,std::string element)
} }


if(!data->explicit_size) if(!data->explicit_size)
errorstream<<"WARNING: invalid use of background without a size[] element"<<std::endl; warningstream<<"invalid use of background without a size[] element"<<std::endl;
m_backgrounds.push_back(ImageDrawSpec(name, pos, geom)); m_backgrounds.push_back(ImageDrawSpec(name, pos, geom));
return; return;
} }
Expand Down Expand Up @@ -982,7 +982,7 @@ void GUIFormSpecMenu::parseSimpleField(parserData* data,
core::rect<s32> rect; core::rect<s32> rect;


if(data->explicit_size) if(data->explicit_size)
errorstream<<"WARNING: invalid use of unpositioned \"field\" in inventory"<<std::endl; warningstream<<"invalid use of unpositioned \"field\" in inventory"<<std::endl;


v2s32 pos = padding + AbsoluteRect.UpperLeftCorner; v2s32 pos = padding + AbsoluteRect.UpperLeftCorner;
pos.Y = ((m_fields.size()+2)*60); pos.Y = ((m_fields.size()+2)*60);
Expand Down Expand Up @@ -1088,7 +1088,7 @@ void GUIFormSpecMenu::parseTextArea(parserData* data,
core::rect<s32> rect = core::rect<s32>(pos.X, pos.Y, pos.X+geom.X, pos.Y+geom.Y); core::rect<s32> rect = core::rect<s32>(pos.X, pos.Y, pos.X+geom.X, pos.Y+geom.Y);


if(!data->explicit_size) if(!data->explicit_size)
errorstream<<"WARNING: invalid use of positioned "<<type<<" without a size[] element"<<std::endl; warningstream<<"invalid use of positioned "<<type<<" without a size[] element"<<std::endl;


if(m_form_src) if(m_form_src)
default_val = m_form_src->resolveText(default_val); default_val = m_form_src->resolveText(default_val);
Expand Down Expand Up @@ -1195,7 +1195,7 @@ void GUIFormSpecMenu::parseLabel(parserData* data,std::string element)
pos.Y += (stof(v_pos[1]) + 7.0/30.0) * (float)spacing.Y; pos.Y += (stof(v_pos[1]) + 7.0/30.0) * (float)spacing.Y;


if(!data->explicit_size) if(!data->explicit_size)
errorstream<<"WARNING: invalid use of label without a size[] element"<<std::endl; warningstream<<"invalid use of label without a size[] element"<<std::endl;


text = unescape_string(text); text = unescape_string(text);
std::vector<std::string> lines = split(text, '\n'); std::vector<std::string> lines = split(text, '\n');
Expand Down Expand Up @@ -1260,7 +1260,7 @@ void GUIFormSpecMenu::parseVertLabel(parserData* data,std::string element)
//actually text.length() would be correct but adding +1 avoids to break all mods //actually text.length() would be correct but adding +1 avoids to break all mods


if(!data->explicit_size) if(!data->explicit_size)
errorstream<<"WARNING: invalid use of label without a size[] element"<<std::endl; warningstream<<"invalid use of label without a size[] element"<<std::endl;


std::wstring label = L""; std::wstring label = L"";


Expand Down Expand Up @@ -1326,7 +1326,7 @@ void GUIFormSpecMenu::parseImageButton(parserData* data,std::string element,
core::rect<s32> rect = core::rect<s32>(pos.X, pos.Y, pos.X+geom.X, pos.Y+geom.Y); core::rect<s32> rect = core::rect<s32>(pos.X, pos.Y, pos.X+geom.X, pos.Y+geom.Y);


if(!data->explicit_size) if(!data->explicit_size)
errorstream<<"WARNING: invalid use of image_button without a size[] element"<<std::endl; warningstream<<"invalid use of image_button without a size[] element"<<std::endl;


image_name = unescape_string(image_name); image_name = unescape_string(image_name);
pressed_image_name = unescape_string(pressed_image_name); pressed_image_name = unescape_string(pressed_image_name);
Expand Down Expand Up @@ -1449,9 +1449,8 @@ void GUIFormSpecMenu::parseItemImageButton(parserData* data,std::string element)
{ {


if (m_gamedef == 0) { if (m_gamedef == 0) {
errorstream << warningstream << "invalid use of item_image_button with m_gamedef==0"
"WARNING: invalid use of item_image_button with m_gamedef==0" << std::endl;
<< std::endl;
return; return;
} }


Expand Down Expand Up @@ -1479,7 +1478,7 @@ void GUIFormSpecMenu::parseItemImageButton(parserData* data,std::string element)
core::rect<s32> rect = core::rect<s32>(pos.X, pos.Y, pos.X+geom.X, pos.Y+geom.Y); core::rect<s32> rect = core::rect<s32>(pos.X, pos.Y, pos.X+geom.X, pos.Y+geom.Y);


if(!data->explicit_size) if(!data->explicit_size)
errorstream<<"WARNING: invalid use of item_image_button without a size[] element"<<std::endl; warningstream<<"invalid use of item_image_button without a size[] element"<<std::endl;


IItemDefManager *idef = m_gamedef->idef(); IItemDefManager *idef = m_gamedef->idef();
ItemStack item; ItemStack item;
Expand Down Expand Up @@ -2158,15 +2157,15 @@ void GUIFormSpecMenu::drawList(const ListDrawSpec &s, int phase)


Inventory *inv = m_invmgr->getInventory(s.inventoryloc); Inventory *inv = m_invmgr->getInventory(s.inventoryloc);
if(!inv){ if(!inv){
infostream<<"GUIFormSpecMenu::drawList(): WARNING: " warningstream<<"GUIFormSpecMenu::drawList(): "
<<"The inventory location " <<"The inventory location "
<<"\""<<s.inventoryloc.dump()<<"\" doesn't exist" <<"\""<<s.inventoryloc.dump()<<"\" doesn't exist"
<<std::endl; <<std::endl;
return; return;
} }
InventoryList *ilist = inv->getList(s.listname); InventoryList *ilist = inv->getList(s.listname);
if(!ilist){ if(!ilist){
infostream<<"GUIFormSpecMenu::drawList(): WARNING: " warningstream<<"GUIFormSpecMenu::drawList(): "
<<"The inventory list \""<<s.listname<<"\" @ \"" <<"The inventory list \""<<s.listname<<"\" @ \""
<<s.inventoryloc.dump()<<"\" doesn't exist" <<s.inventoryloc.dump()<<"\" doesn't exist"
<<std::endl; <<std::endl;
Expand Down
Loading

0 comments on commit 96cc5b3

Please sign in to comment.