Switch to the new logging macro.

This commit is contained in:
Guillaume Melquiond 2005-03-26 17:10:32 +00:00
parent d2154990c3
commit d501297a65
43 changed files with 94 additions and 94 deletions

View file

@ -45,8 +45,8 @@
#include <string>
#include <sstream>
#define LOG_NG lg::info(lg::engine)
#define ERR_NW lg::err(lg::network)
#define LOG_NG LOG_STREAM(info, engine)
#define ERR_NW LOG_STREAM(err, network)
struct castle_cost_calculator : cost_calculator
{
@ -1296,7 +1296,7 @@ void advance_unit(const game_data& info,
statistics::advance_unit(new_unit);
preferences::encountered_units().insert(new_unit.type().name());
lg::info(lg::config) << "Added '" << new_unit.type().name() << "' to encountered units\n";
LOG_STREAM(info, config) << "Added '" << new_unit.type().name() << "' to encountered units\n";
units.erase(loc);
units.insert(std::pair<gamemap::location,unit>(loc,new_unit));

View file

@ -34,7 +34,7 @@
#include <iostream>
#define LOG_AI lg::info(lg::ai)
#define LOG_AI LOG_STREAM(info, ai)
///a trivial ai that sits around doing absolutely nothing
class idle_ai : public ai_interface {
@ -195,7 +195,7 @@ ai_interface* create_ai(const std::string& name, ai_interface::info& info)
else if(name == "ai2")
return new ai2(info);
else if(name != "")
lg::err(lg::ai) << "AI not found: '" << name << "'\n";
LOG_STREAM(err, ai) << "AI not found: '" << name << "'\n";
return new ai(info);
}
@ -374,7 +374,7 @@ gamemap::location ai_interface::move_unit_partial(location from, location to, st
log_scope2(ai, "move_unit");
unit_map::iterator u_it = info_.units.find(from);
if(u_it == info_.units.end()) {
lg::err(lg::ai) << "Could not find unit at " << from.x << ", " << from.y << "\n";
LOG_STREAM(err, ai) << "Could not find unit at " << from.x << ", " << from.y << "\n";
wassert(false);
return location();
}
@ -911,7 +911,7 @@ bool ai::do_combat(std::map<gamemap::location,paths>& possible_moves, const move
const location arrived_at = move_unit(from,to,possible_moves);
if(arrived_at != to) {
lg::warn(lg::ai) << "unit moving to attack has ended up unexpectedly at "
LOG_STREAM(warn, ai) << "unit moving to attack has ended up unexpectedly at "
<< (arrived_at.x + 1) << "," << (arrived_at.y + 1) << " when moving to "
<< (to.x + 1) << "," << (to.y + 1) << " moved from "
<< (from.x + 1) << "," << (from.y + 1) << "\n";
@ -940,7 +940,7 @@ void ai_interface::attack_enemy(const location& u, const location& target, int w
if(info_.units.count(u) && info_.units.count(target)) {
if(info_.units.find(target)->second.stone()) {
lg::err(lg::ai) << "attempt to attack unit that is turned to stone\n";
LOG_STREAM(err, ai) << "attempt to attack unit that is turned to stone\n";
return;
}
@ -1345,7 +1345,7 @@ bool ai::move_to_targets(std::map<gamemap::location,paths>& possible_moves, move
//we didn't arrive at our intended destination. We return true, meaning that
//the AI algorithm should be recalculated from the start.
if(arrived_at != move.second) {
lg::warn(lg::ai) << "didn't arrive at destination\n";
LOG_STREAM(warn, ai) << "didn't arrive at destination\n";
return true;
}

View file

@ -27,7 +27,7 @@
#include <iostream>
#include <set>
#define LOG_AI lg::info(lg::ai)
#define LOG_AI LOG_STREAM(info, ai)
const int max_positions = 10000;
@ -258,7 +258,7 @@ int ai::choose_weapon(const location& att, const location& def,
cur_stats = cache_itor->stats;
if(!(size_t(cache_itor->weapon) < itor->second.attacks().size())) {
lg::err(lg::ai) << "cached illegal weapon: " << cache_itor->weapon
LOG_STREAM(err, ai) << "cached illegal weapon: " << cache_itor->weapon
<< "/" << itor->second.attacks().size() << "\n";
}

View file

@ -22,7 +22,7 @@
#include <iostream>
#define LOG_AI lg::info(lg::ai)
#define LOG_AI LOG_STREAM(info, ai)
struct move_cost_calculator : cost_calculator
{

View file

@ -23,7 +23,7 @@
#include "wassert.hpp"
#include "serialization/string_utils.hpp"
#define ERR_NG lg::err(lg::engine)
#define ERR_NG LOG_STREAM(err, engine)
namespace {
@ -706,7 +706,7 @@ void terrain_builder::parse_config(const config &cfg)
if((**tc)["pos"].size()) {
int pos = atoi((**tc)["pos"].c_str());
if(anchors.find(pos) == anchors.end()) {
lg::warn(lg::engine) << "Invalid anchor!\n";
LOG_STREAM(warn, engine) << "Invalid anchor!\n";
continue;
}

View file

@ -7,7 +7,7 @@
#include "wassert.hpp"
#include "serialization/string_utils.hpp"
#define LOG_NG lg::info(lg::engine)
#define LOG_NG LOG_STREAM(info, engine)
cave_map_generator::cave_map_generator(const config* cfg) : wall_('W'), clear_('u'), village_('D'), castle_('o'),
cfg_(cfg), width_(50), height_(50), village_density_(0),

View file

@ -21,7 +21,7 @@
#include "variable.hpp"
#include "wassert.hpp"
#define ERR_CF lg::err(lg::config)
#define ERR_CF LOG_STREAM(err, config)
config::config(const config& cfg)
{

View file

@ -43,8 +43,8 @@
#include <time.h>
#include <vector>
#define LOG_DP lg::info(lg::display)
#define ERR_G lg::err(lg::general)
#define LOG_DP LOG_STREAM(info, display)
#define ERR_G LOG_STREAM(err, general)
namespace dialogs
{

View file

@ -43,7 +43,7 @@
#include <iostream>
#include <sstream>
#define ERR_DP lg::err(lg::display)
#define ERR_DP LOG_STREAM(err, display)
std::map<gamemap::location,fixed_t> display::debugHighlights_;
@ -109,7 +109,7 @@ display::display(unit_map& units, CVideo& video, const gamemap& map,
flag = teams_[i].flag();
}
lg::info(lg::display) << "Adding flag for team " << i << " from animation " << flag << "\n";
LOG_STREAM(info, display) << "Adding flag for team " << i << " from animation " << flag << "\n";
flags_.push_back(animated<image::locator>(flag));
flags_.back().start_animation(0, animated<image::locator>::INFINITE_CYCLES);
}

View file

@ -63,7 +63,7 @@ BPath be_path;
#include "scoped_resource.hpp"
#include "util.hpp"
#define LOG_G lg::info(lg::general)
#define LOG_G LOG_STREAM(info, general)
#ifdef USE_ZIPIOS
#include <sstream>

View file

@ -39,9 +39,9 @@
#include <stack>
#include <string>
#define LOG_FT lg::info(lg::display)
#define WRN_FT lg::warn(lg::display)
#define ERR_FT lg::err(lg::display)
#define LOG_FT LOG_STREAM(info, display)
#define WRN_FT LOG_STREAM(warn, display)
#define ERR_FT LOG_STREAM(err, display)
//Deliberately breaking compilation with the original SDL_ttf library. Remove
//the lines below to be able to do this anyway, however this is buggy and may

View file

@ -39,10 +39,10 @@
#include <set>
#include <string>
#define LOG_NG lg::info(lg::engine)
#define WRN_NG lg::warn(lg::engine)
#define ERR_NG lg::err(lg::engine)
#define LOG_DP lg::info(lg::display)
#define LOG_NG LOG_STREAM(info, engine)
#define WRN_NG LOG_STREAM(warn, engine)
#define ERR_NG LOG_STREAM(err, engine)
#define LOG_DP LOG_STREAM(info, display)
namespace game_events {

View file

@ -116,7 +116,7 @@ struct game_state
std::map<std::string, player_info>::iterator found=players.find(id);
if(found==players.end()) {
lg::warn(lg::engine) << "player " << id << " does not exist." << std::endl;
LOG_STREAM(warn, engine) << "player " << id << " does not exist." << std::endl;
return NULL;
} else {
return &found->second;

View file

@ -32,7 +32,7 @@
#include <cstdlib>
#include <map>
#define ERR_G lg::err(lg::general)
#define ERR_G LOG_STREAM(err, general)
namespace {

View file

@ -17,8 +17,8 @@
#include <map>
#include <string>
#define LOG_DP lg::info(lg::display)
#define ERR_DP lg::err(lg::display)
#define LOG_DP LOG_STREAM(info, display)
#define ERR_DP LOG_STREAM(err, display)
namespace {

View file

@ -27,8 +27,8 @@
#include <iostream>
#include <sstream>
#define ERR_CF lg::err(lg::config)
#define LOG_G lg::info(lg::general)
#define ERR_CF LOG_STREAM(err, config)
#define LOG_G LOG_STREAM(info, general)
gamemap::location gamemap::location::null_location;

View file

@ -11,7 +11,7 @@
#include <string>
#include <vector>
#define ERR_CF lg::err(lg::config)
#define ERR_CF LOG_STREAM(err, config)
map_generator* create_map_generator(const std::string& name, const config* cfg)
{

View file

@ -20,8 +20,8 @@
#include "util.hpp"
#include "serialization/string_utils.hpp"
#define ERR_CF lg::err(lg::config)
#define LOG_NG lg::info(lg::engine)
#define ERR_CF LOG_STREAM(err, config)
#define LOG_NG LOG_STREAM(info, engine)
config map_generator::create_scenario(const std::vector<std::string>& args)
{

View file

@ -29,7 +29,7 @@
#include "replay.hpp"
#include "video.hpp"
#define LOG_NW lg::info(lg::network)
#define LOG_NW LOG_STREAM(info, network)
namespace {

View file

@ -25,10 +25,10 @@
#include "wassert.hpp"
#include "serialization/string_utils.hpp"
#define LOG_NW lg::info(lg::network)
#define ERR_NW lg::err(lg::network)
#define LOG_CF lg::info(lg::config)
#define ERR_CF lg::err(lg::config)
#define LOG_NW LOG_STREAM(info, network)
#define ERR_NW LOG_STREAM(err, network)
#define LOG_CF LOG_STREAM(info, config)
#define ERR_CF LOG_STREAM(err, config)
namespace {
const char* controller_names[] = {

View file

@ -23,8 +23,8 @@
#include "sound.hpp"
#include "video.hpp"
#define LOG_NW lg::info(lg::network)
#define ERR_NW lg::err(lg::network)
#define LOG_NW LOG_STREAM(info, network)
#define ERR_NW LOG_STREAM(err, network)
namespace mp {

View file

@ -26,8 +26,8 @@
#include "wml_separators.hpp"
#include "serialization/string_utils.hpp"
#define LOG_NW lg::info(lg::network)
#define ERR_NW lg::err(lg::network)
#define LOG_NW LOG_STREAM(info, network)
#define ERR_NW LOG_STREAM(err, network)
namespace {
const SDL_Rect leader_pane_position = {-260,-370,260,370};

View file

@ -19,8 +19,8 @@
#include <signal.h>
#define LOG_NW lg::info(lg::network)
#define WRN_NW lg::warn(lg::network)
#define LOG_NW LOG_STREAM(info, network)
#define WRN_NW LOG_STREAM(warn, network)
// only warnings and not errors to avoid DoS by log flooding
namespace {
@ -168,7 +168,7 @@ manager::manager(size_t nthreads) : free_(true)
#endif
if(SDLNet_Init() == -1) {
lg::err(lg::network) << "could not initialize SDLNet; throwing error...\n";
LOG_STREAM(err, network) << "could not initialize SDLNet; throwing error...\n";
throw error(SDL_GetError());
}

View file

@ -13,7 +13,7 @@
#include <map>
#include <vector>
#define LOG_NW lg::info(lg::network)
#define LOG_NW LOG_STREAM(info, network)
namespace {

View file

@ -25,7 +25,7 @@ class gamestatus;
#include <cmath>
#include <iostream>
#define LOG_PF lg::info(lg::engine)
#define LOG_PF LOG_STREAM(info, engine)
typedef std::vector<gamemap::location> vector_location;
typedef std::vector<a_star_node*> vector_a_star_node;

View file

@ -47,7 +47,7 @@
#include <iostream>
#include <iterator>
#define LOG_NG lg::info(lg::engine)
#define LOG_NG LOG_STREAM(info, engine)
namespace {
int placing_score(const config& side, const gamemap& map, const gamemap::location& pos)

View file

@ -489,7 +489,7 @@ void turn_info::mouse_press(const SDL_MouseButtonEvent& event)
if (m != NULL)
show_menu(m->items(),event.x,event.y,true);
else
lg::warn(lg::display) << "no context menu found...\n";
LOG_STREAM(warn, display) << "no context menu found...\n";
}
} else if(is_middle_click(event) && event.state == SDL_PRESSED) {
// clicked on a hex on the minimap? then initiate minimap scrolling
@ -998,7 +998,7 @@ void turn_info::move_unit_to_loc(const unit_map::const_iterator& ui, const gamem
}
void turn_info::start_interactive_turn() {
lg::info(lg::engine) << "done gotos\n";
LOG_STREAM(info, engine) << "done gotos\n";
start_ncmd_ = recorder.ncommands();
}
@ -1346,7 +1346,7 @@ void turn_info::undo()
player_info* const player = state_of_game_.get_player(teams_[team_num_-1].save_id());
if(player == NULL) {
lg::err(lg::engine) << "trying to undo a recall for side " << team_num_
LOG_STREAM(err, engine) << "trying to undo a recall for side " << team_num_
<< ", which has no recall list!\n";
} else {
// Undo a recall action
@ -1372,7 +1372,7 @@ void turn_info::undo()
const unit_map::iterator u = units_.find(route.front());
if(u == units_.end()) {
//this can actually happen if the scenario designer has abused the [allow_undo] command
lg::err(lg::engine) << "Illegal 'undo' found. Possible abuse of [allow_undo]?\n";
LOG_STREAM(err, engine) << "Illegal 'undo' found. Possible abuse of [allow_undo]?\n";
return;
}
@ -1434,7 +1434,7 @@ void turn_info::redo()
if(action.is_recall()) {
player_info *player=state_of_game_.get_player(teams_[team_num_-1].save_id());
if(!player) {
lg::err(lg::engine) << "trying to redo a recall for side " << team_num_
LOG_STREAM(err, engine) << "trying to redo a recall for side " << team_num_
<< ", which has no recall list!\n";
} else {
// Redo recall
@ -1765,7 +1765,7 @@ void turn_info::recruit()
const std::map<std::string,unit_type>::const_iterator
u_type = gameinfo_.unit_types.find(*it);
if(u_type == gameinfo_.unit_types.end()) {
lg::err(lg::engine) << "could not find unit '" << *it << "'";
LOG_STREAM(err, engine) << "could not find unit '" << *it << "'";
return;
}
@ -1924,7 +1924,7 @@ void turn_info::recall()
player_info *player = state_of_game_.get_player(teams_[team_num_-1].save_id());
if(!player) {
lg::err(lg::engine) << "cannot recall a unit for side " << team_num_
LOG_STREAM(err, engine) << "cannot recall a unit for side " << team_num_
<< ", which has no recall list!\n";
return;
}
@ -2675,7 +2675,7 @@ turn_info::PROCESS_DATA_RESULT turn_info::process_network_data(const config& cfg
if(cfg["side_drop"] != "") {
const size_t side = atoi(cfg["side_drop"].c_str())-1;
if(side >= teams_.size()) {
lg::err(lg::network) << "unknown side " << side << " is dropping game\n";
LOG_STREAM(err, network) << "unknown side " << side << " is dropping game\n";
throw network::error("");
}
@ -2805,7 +2805,7 @@ void turn_info::enter_textbox()
do_command(textbox_.box->text());
break;
default:
lg::err(lg::display) << "unknown textbox mode\n";
LOG_STREAM(err, display) << "unknown textbox mode\n";
}
close_textbox();
@ -2872,14 +2872,14 @@ void turn_info::tab_textbox()
break;
}
default:
lg::err(lg::display) << "unknown textbox mode\n";
LOG_STREAM(err, display) << "unknown textbox mode\n";
}
}
const unit_map& turn_info::visible_units() const
{
if(viewing_team().uses_shroud() == false && viewing_team().uses_fog() == false) {
lg::info(lg::engine) << "all units are visible...\n";
LOG_STREAM(info, engine) << "all units are visible...\n";
return units_;
}
@ -2890,7 +2890,7 @@ const unit_map& turn_info::visible_units() const
}
}
lg::info(lg::engine) << "number of visible units: " << visible_units_.size() << "\n";
LOG_STREAM(info, engine) << "number of visible units: " << visible_units_.size() << "\n";
return visible_units_;
}

View file

@ -39,8 +39,8 @@
#include <set>
#include <sstream>
#define LOG_NW lg::info(lg::network)
#define ERR_NW lg::err(lg::network)
#define LOG_NW LOG_STREAM(info, network)
#define ERR_NW LOG_STREAM(err, network)
//functions to verify that the unit structure on both machines is identical
namespace {

View file

@ -25,7 +25,7 @@
#include <iostream>
#include <map>
#define ERR_DP lg::err(lg::display)
#define ERR_DP LOG_STREAM(err, display)
SDLKey sdl_keysym_from_name(std::string const &keyname)
{

View file

@ -22,7 +22,7 @@
#include <iostream>
#include <sstream>
#define ERR_CF lg::err(lg::config)
#define ERR_CF LOG_STREAM(err, config)
//data compression. Compression is designed for network traffic.
//assumptions compression is based on:

View file

@ -30,9 +30,9 @@
#include <sstream>
#include <stack>
#define ERR_CF lg::err(lg::config)
#define WRN_CF lg::warn(lg::config)
#define LOG_CF lg::info(lg::config)
#define ERR_CF LOG_STREAM(err, config)
#define WRN_CF LOG_STREAM(warn, config)
#define LOG_CF LOG_STREAM(info, config)
static const int max_recursion_levels = 100;

View file

@ -25,8 +25,8 @@
#include "serialization/preprocessor.hpp"
#include "serialization/string_utils.hpp"
#define ERR_CF lg::err(lg::config)
#define LOG_CF lg::info(lg::config)
#define ERR_CF LOG_STREAM(err, config)
#define LOG_CF LOG_STREAM(info, config)
bool preproc_define::operator==(preproc_define const &v) const {
return value == v.value && arguments == v.arguments;

View file

@ -23,7 +23,7 @@
#include "variable.hpp"
#include "SDL_types.h"
#define ERR_GENERAL lg::err(lg::general)
#define ERR_GENERAL LOG_STREAM(err, general)
namespace {

View file

@ -43,9 +43,9 @@
#include <iostream>
#include <numeric>
#define ERR_DP lg::err(lg::display)
#define LOG_DP lg::info(lg::display)
#define ERR_G lg::err(lg::general)
#define ERR_DP LOG_STREAM(err, display)
#define LOG_DP LOG_STREAM(info, display)
#define ERR_G LOG_STREAM(err, general)
namespace {
bool is_in_dialog = false;
@ -858,7 +858,7 @@ int dialog_action_receive_network::do_action()
if(res_ != 0)
return CONNECTION_COMPLETE;
else if(network::current_transfer_stats().first != stats_.first) {
lg::info(lg::network) << "continuing connection...\n";
LOG_STREAM(info, network) << "continuing connection...\n";
return CONNECTION_CONTINUING;
} else
return CONTINUE_DIALOG;

View file

@ -27,7 +27,7 @@
#include <cstdlib>
#include <sstream>
#define LOG_NG lg::info(lg::engine)
#define LOG_NG LOG_STREAM(info, engine)
namespace {
std::vector<team>* teams = NULL;

View file

@ -13,7 +13,7 @@
#include <cstdlib>
#include <sstream>
#define LOG_DP lg::info(lg::display)
#define LOG_DP LOG_STREAM(info, display)
namespace {
const SDL_Rect empty_rect = {0,0,0,0};
@ -455,7 +455,7 @@ bool theme::set_resolution(const SDL_Rect& screen)
if(current == resolutions.end()) {
if(!resolutions.empty())
lg::err(lg::display) << "No valid resolution found\n";
LOG_STREAM(err, display) << "No valid resolution found\n";
return false;
}

View file

@ -22,8 +22,8 @@
#include "SDL_ttf.h"
#define LOG_DP lg::info(lg::display)
#define ERR_DP lg::err(lg::display)
#define LOG_DP LOG_STREAM(info, display)
#define ERR_DP LOG_STREAM(err, display)
namespace {

View file

@ -31,7 +31,7 @@
#include <iostream>
#include <sstream>
#define LOG_UT lg::info(lg::engine)
#define LOG_UT LOG_STREAM(info, engine)
namespace {
const std::string ModificationTypes[] = { "object", "trait", "advance" };

View file

@ -15,7 +15,7 @@
#include "util.hpp"
#include "wassert.hpp"
#define LOG_DP lg::info(lg::display)
#define LOG_DP LOG_STREAM(info, display)
namespace
{
@ -126,7 +126,7 @@ void move_unit_between(display& disp, const gamemap& map, const gamemap::locatio
}
if(image == NULL) {
lg::err(lg::display) << "failed to get image " << u.type().image_moving() << "\n";
LOG_STREAM(err, display) << "failed to get image " << u.type().image_moving() << "\n";
return;
}

View file

@ -380,7 +380,7 @@ int unit_movement_type::movement_cost(const gamemap& map,gamemap::TERRAIN terrai
if(movement_costs != NULL) {
if(underlying.size() != 1) {
lg::err(lg::config) << "terrain '" << terrain << "' has " << underlying.size() << " underlying names - 0 expected\n";
LOG_STREAM(err, config) << "terrain '" << terrain << "' has " << underlying.size() << " underlying names - 0 expected\n";
return impassable;
}
@ -439,7 +439,7 @@ int unit_movement_type::defense_modifier(const gamemap& map,gamemap::TERRAIN ter
if(defense != NULL) {
if(underlying.size() != 1) {
lg::err(lg::config) << "terrain '" << terrain << "' has " << underlying.size() << " underlying names - 0 expected\n";
LOG_STREAM(err, config) << "terrain '" << terrain << "' has " << underlying.size() << " underlying names - 0 expected\n";
return 100;
}
@ -630,7 +630,7 @@ unit_type::unit_type(const config& cfg, const movement_type_map& mv_types,
else if(align == "neutral")
alignment_ = NEUTRAL;
else {
lg::err(lg::config) << "Invalid alignment found for " << name() << ": '" << align << "'\n";
LOG_STREAM(err, config) << "Invalid alignment found for " << name() << ": '" << align << "'\n";
alignment_ = NEUTRAL;
}

View file

@ -22,8 +22,8 @@
#include "log.hpp"
#include "video.hpp"
#define LOG_DP lg::info(lg::display)
#define ERR_DP lg::err(lg::display)
#define LOG_DP LOG_STREAM(info, display)
#define ERR_DP LOG_STREAM(err, display)
#define TEST_VIDEO_ON 0

View file

@ -20,7 +20,7 @@ void wassert(bool expression)
{
// crash if expression is false
if(! expression) {
lg::err(lg::general) << "Assertion failure" << "\n";
LOG_STREAM(err, general) << "Assertion failure" << "\n";
*reinterpret_cast<int*>(0) = 5;
}
}

View file

@ -341,7 +341,7 @@ void textbox::handle_event(const SDL_Event& event)
//Sanity check: verify that selection start and end are within text
//boundaries
if(is_selection() && !(size_t(selstart_) <= text_.size() && size_t(selend_) <= text_.size())) {
lg::warn(lg::display) << "out-of-boundary selection\n";
LOG_STREAM(warn, display) << "out-of-boundary selection\n";
selstart_ = selend_ = -1;
}
@ -463,7 +463,7 @@ void textbox::handle_event(const SDL_Event& event)
if(!(c == SDLK_UP || c == SDLK_DOWN || c == SDLK_LEFT || c == SDLK_RIGHT ||
c == SDLK_DELETE || c == SDLK_BACKSPACE || c == SDLK_END || c == SDLK_HOME)) {
if(character != 0)
lg::info(lg::display) << "Char: " << character << ", c = " << c << "\n";
LOG_STREAM(info, display) << "Char: " << character << ", c = " << c << "\n";
if(event.key.keysym.mod & KMOD_CTRL) {
switch(c) {