From f1d9880006cf713597c1fc573f83db75062712c9 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sun, 11 Mar 2012 04:15:45 +0200 Subject: [PATCH] Clean up log messages everywhere --- .../games/mesetint/mods/experimental/init.lua | 6 +- src/clouds.cpp | 3 - src/content_sao.cpp | 4 +- src/craftdef.cpp | 2 +- src/debug.cpp | 4 +- src/environment.cpp | 12 +- src/gettext.h | 6 +- src/itemdef.cpp | 4 +- src/main.cpp | 14 +- src/map.cpp | 49 +-- src/nodedef.cpp | 2 +- src/porting.cpp | 5 - src/script.cpp | 2 +- src/scriptapi.cpp | 30 +- src/server.cpp | 321 ++++++++++-------- src/server.h | 21 +- src/settings.h | 2 - 17 files changed, 243 insertions(+), 244 deletions(-) diff --git a/share/server/games/mesetint/mods/experimental/init.lua b/share/server/games/mesetint/mods/experimental/init.lua index 1ee3fdc2e..364eeb10c 100644 --- a/share/server/games/mesetint/mods/experimental/init.lua +++ b/share/server/games/mesetint/mods/experimental/init.lua @@ -609,8 +609,8 @@ minetest.register_abm({ end, })--]] -print("experimental modname="..dump(minetest.get_current_modname())) -print("experimental modpath="..dump(minetest.get_modpath("experimental"))) -print("experimental worldpath="..dump(minetest.get_worldpath())) +minetest.log("experimental modname="..dump(minetest.get_current_modname())) +minetest.log("experimental modpath="..dump(minetest.get_modpath("experimental"))) +minetest.log("experimental worldpath="..dump(minetest.get_worldpath())) -- END diff --git a/src/clouds.cpp b/src/clouds.cpp index 232436597..784d611f2 100644 --- a/src/clouds.cpp +++ b/src/clouds.cpp @@ -38,8 +38,6 @@ Clouds::Clouds( m_camera_pos(0,0), m_time(0) { - dstream<<__FUNCTION_NAME<dump()< +#include "log.h" #if USE_GETTEXT #include @@ -41,9 +41,9 @@ inline void changeCtype(const char *l) char *ret = NULL; ret = setlocale(LC_CTYPE, l); if(ret == NULL) - std::cout<<"locale could not be set"< "<__| \\___ >____ > |__| "<::Iterator i = m_modspaths.begin(); i != m_modspaths.end(); i++){ std::string modspath = *i; - infostream<<" "<::Iterator i = m_mods.begin(); + i != m_mods.end(); i++){ + const ModSpec &mod = *i; + infostream<::Iterator i = m_mods.begin(); i != m_mods.end(); i++){ const ModSpec &mod = *i; - infostream<<"Server: Loading mod \""<__| \\___ >____ > |__| "<peer_id, 0, reply, true); - infostream<<"Server: Sent object remove/add: " + verbosestream<<"Server: Sent object remove/add: " <= 4) disable_single_change_sending = true; - bool got_any_events = false; + int event_count = m_unsent_map_edit_queue.size(); // We'll log the amount of each Profiler prof; while(m_unsent_map_edit_queue.size() != 0) { - got_any_events = true; - MapEditEvent* event = m_unsent_map_edit_queue.pop_front(); // Players far away from the change are stored here. @@ -1776,10 +1802,12 @@ void Server::AsyncRunStep() break;*/ } - if(got_any_events) - { + if(event_count >= 5){ infostream<<"Server: MapEditEvents:"<serialization_version; @@ -1920,7 +1950,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) if(datasize < 2+1+PLAYERNAME_SIZE) return; - infostream<<"Server: Got TOSERVER_INIT from " + verbosestream<<"Server: Got TOSERVER_INIT from " < tosend; - u16 numtextures = readU16(is); - for(int i = 0; i < numtextures; i++) { + infostream<<"Sending "<getName() + verbosestream<<"TOSERVER_INTERACT: "<getName() <<" tried to interact, but is dead!"<getActiveObject(pointed.object_id); if(pointed_object == NULL) { - infostream<<"TOSERVER_INTERACT: " + verbosestream<<"TOSERVER_INTERACT: " "pointed object is NULL"<getName()<<" punches object " - <getDescription()<getWieldedItem(); ToolCapabilities toolcap = @@ -3031,7 +3070,8 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) return; actionstream<getName()<<" right-clicks object " - <getDescription()<rightClick(srp); @@ -3238,7 +3278,7 @@ core::list Server::getPlayerInfo() void Server::peerAdded(con::Peer *peer) { DSTACK(__FUNCTION_NAME); - infostream<<"Server::peerAdded(): peer->id=" + verbosestream<<"Server::peerAdded(): peer->id=" <id<id=" + verbosestream<<"Server::deletingPeer(): peer->id=" <id<<", timeout="<::Iterator i = m_mods.begin(); - i != m_mods.end(); i++){ - const ModSpec &mod = *i; - std::string texturepath = mod.path + DIR_DELIM + "textures"; - std::vector dirlist = fs::GetDirListing(texturepath); - for(u32 j=0; j dirlist = fs::GetDirListing(texturepath); + for(u32 j=0; jm_Textures[tname] = TextureInformation(tpath,digest_string); - infostream<<"Server::PrepareTextures(): added sha1 for "<< tname <m_Textures[tname] = TextureInformation(tpath,digest_string); + verbosestream<<"Server: sha1 for "< texture_announcements; @@ -3881,7 +3923,6 @@ void Server::SendTextureAnnouncement(u16 peer_id){ // Make data buffer std::string s = os.str(); - infostream<<"Server::SendTextureAnnouncement(): Send to client"< data((u8*)s.c_str(), s.size()); // Send as reliable @@ -3906,7 +3947,8 @@ struct SendableTexture void Server::SendTexturesRequested(u16 peer_id,core::list tosend) { DSTACK(__FUNCTION_NAME); - infostream<<"Server::SendTexturesRequested(): Sending textures to client"< tosend // Make data buffer std::string s = os.str(); - infostream<<"Server::SendTexturesRequested(): bunch "<clear(); } } - - /* - Player info - */ - static int counter = 0; - counter--; - if(counter <= 0) - { - counter = 10; - - core::list list = server.getPlayerInfo(); - core::list::Iterator i; - static u32 sum_old = 0; - u32 sum = PIChecksum(list); - if(sum != sum_old) - { - infostream<PrintLine(&infostream); - } - } - sum_old = sum; - } } } diff --git a/src/server.h b/src/server.h index 50cd5b285..a1d7e5df7 100644 --- a/src/server.h +++ b/src/server.h @@ -40,6 +40,23 @@ class IWritableItemDefManager; class IWritableNodeDefManager; class IWritableCraftDefManager; +class ServerError : public std::exception +{ +public: + ServerError(const std::string &s) + { + m_s = "ServerError: "; + m_s += s; + } + virtual ~ServerError() throw() + {} + virtual const char * what() const throw() + { + return m_s.c_str(); + } + std::string m_s; +}; + /* Some random functions */ @@ -211,8 +228,6 @@ struct PlayerInfo void PrintLine(std::ostream *s); }; -u32 PIChecksum(core::list &l); - /* Used for queueing and sorting block transfers in containers @@ -608,7 +623,7 @@ private: { Player *player = m_env->getPlayer(peer_id); if(player == NULL) - return "[id="+itos(peer_id); + return "[id="+itos(peer_id)+"]"; return player->getName(); } diff --git a/src/settings.h b/src/settings.h index 9eb2254f0..0b828e2a5 100644 --- a/src/settings.h +++ b/src/settings.h @@ -425,8 +425,6 @@ public: n = m_defaults.find(name); if(n == NULL) { - infostream<<"Settings: Setting not found: \"" - <