rename _log_warn to log_warning and get rid of the cumbersome #define

This commit is contained in:
Enno Rehling 2012-05-16 15:52:37 -07:00
parent 9065334677
commit 14d62afb0d
27 changed files with 51 additions and 71 deletions

View File

@ -271,8 +271,7 @@ static void lua_initfamiliar(unit * u)
lua_pop(L, 1);
}
} else {
log_warning(("familiar(%s) calling '%s': not a function.\n",
unitname(u), fname));
log_warning("familiar(%s) calling '%s': not a function.\n", unitname(u), fname);
lua_pop(L, 1);
}

View File

@ -214,8 +214,7 @@ void give_men(int n, unit * u, unit * u2, struct order *ord)
/* werewolves can't be given to non-werewolves and vice-versa */
error = 312;
} else if (u2 && u2->number != 0 && u2->race != u->race) {
log_warning(("faction %s attempts to give %s to %s.\n",
itoa36(u->faction->no), u->race->_name[0], u2->race->_name[1]));
log_warning("faction %s attempts to give %s to %s.\n", itoa36(u->faction->no), u->race->_name[0], u2->race->_name[1]);
error = 139;
} else if (u2 != NULL && (get_racename(u2->attribs)
|| get_racename(u->attribs))) {

View File

@ -1099,8 +1099,7 @@ static int restart_cmd(unit * u, struct order *ord)
if (!checkpasswd(u->faction, (const char *)s_pass, false)) {
cmistake(u, ord, 86, MSG_EVENT);
log_warning(("RESTART with wrong password, faction %s, pass %s\n",
factionid(u->faction), s_pass));
log_warning("RESTART with wrong password, faction %s, pass %s\n", factionid(u->faction), s_pass);
return 0;
}
restart_race(u, frace);
@ -1156,8 +1155,7 @@ static int quit_cmd(unit * u, struct order *ord)
char buffer[64];
write_order(ord, buffer, sizeof(buffer));
cmistake(u, ord, 86, MSG_EVENT);
log_warning(("QUIT with illegal password for faction %s: %s\n",
factionid(f), buffer));
log_warning("QUIT with illegal password for faction %s: %s\n", factionid(f), buffer);
}
return 0;
}
@ -4382,7 +4380,7 @@ void update_subscriptions(void)
strcat(strcpy(zText, basepath()), "/subscriptions");
F = fopen(zText, "r");
if (F == NULL) {
log_warning((0, "could not open %s.\n", zText));
log_warning(0, "could not open %s.\n", zText);
return;
}
for (;;) {

View File

@ -95,7 +95,7 @@ void do_command(const void *keys, struct unit *u, struct order *ord)
skip_token();
if (do_command_i(keys, u, ord) != E_TOK_SUCCESS) {
char *cmd = getcommand(ord);
log_warning(("%s failed command '%s'\n", unitname(u), cmd));
log_warning("%s failed command '%s'\n", unitname(u), cmd);
free(cmd);
}
}

View File

@ -746,7 +746,7 @@ void verify_data(void)
lf = f->no;
log_printf(stdout, "Partei %s:\n", factionid(f));
}
log_warning(("Einheit %s hat %d Personen\n", unitid(u), u->number));
log_warning("Einheit %s hat %d Personen\n", unitid(u), u->number);
}
}
if (f->no != 0 && ((mage > 3 && f->race != new_race[RC_ELF]) || mage > 4))
@ -1143,8 +1143,7 @@ const char *strcheck(const char *s, size_t maxlen)
static char buffer[16 * 1024];
if (strlen(s) > maxlen) {
assert(maxlen < 16 * 1024);
log_warning(("[strcheck] String wurde auf %d Zeichen verkürzt:\n%s\n",
(int)maxlen, s));
log_warning("[strcheck] String wurde auf %d Zeichen verkürzt:\n%s\n", (int)maxlen, s);
strlcpy(buffer, s, maxlen);
return buffer;
}

View File

@ -677,7 +677,7 @@ int read_borders(struct storage *store)
return result;
}
if (!type->name || !to || !from) {
log_warning(("erase invalid border '%s' between '%s' and '%s'\n", type->__name, regionname(from, 0), regionname(to, 0)));
log_warning("erase invalid border '%s' between '%s' and '%s'\n", type->__name, regionname(from, 0), regionname(to, 0));
erase_border(b);
}
}

View File

@ -355,7 +355,7 @@ resource_type *rt_find(const char *name)
break;
}
if (!rtype) {
log_warning(("rt_find: unknown resource '%s'\n", name));
log_warning("rt_find: unknown resource '%s'\n", name);
}
return rtype;
}

View File

@ -944,8 +944,7 @@ boolean knowsspell(const region * r, const unit * u, const spell * sp)
/* Magier? */
mage = get_mage(u);
if (!mage) {
log_warning(("%s ist kein Magier, versucht aber zu zaubern.\n",
unitname(u)));
log_warning("%s ist kein Magier, versucht aber zu zaubern.\n", unitname(u));
return false;
}
/* steht der Spruch in der Spruchliste? */
@ -955,8 +954,7 @@ boolean knowsspell(const region * r, const unit * u, const spell * sp)
return false;
}
if (eff_skill(u, SK_MAGIC, u->region) >= sp->level) {
log_warning(("%s ist hat die erforderliche Stufe, kennt aber %s nicht.\n",
unitname(u), spell_name(sp, default_locale)));
log_warning("%s ist hat die erforderliche Stufe, kennt aber %s nicht.\n", unitname(u), spell_name(sp, default_locale));
}
return false;
}

View File

@ -149,7 +149,7 @@ message *msg_message(const char *name, const char *sig, ...)
memset(args, 0, sizeof(args));
if (!mtype) {
log_warning(("trying to create message of unknown type \"%s\"\n", name));
log_warning("trying to create message of unknown type \"%s\"\n", name);
if (strcmp(name, "missing_message") != 0) {
return msg_message("missing_message", "name", name);
}
@ -200,7 +200,7 @@ caddmessage(region * r, faction * f, const char *s, msg_t mtype, int level)
#define LOG_ENGLISH
#ifdef LOG_ENGLISH
if (f && f->locale != default_locale) {
log_warning(("message for locale \"%s\": %s\n", locale_name(f->locale), s));
log_warning("message for locale \"%s\": %s\n", locale_name(f->locale), s);
}
#endif
unused(level);

View File

@ -81,7 +81,7 @@ int change_resource(unit * u, const resource_type * rtype, int change)
assert(!"undefined resource detected. rtype->uchange not initialized.");
assert(i >= 0);
if (i >= 100000000) {
log_warning(("%s has %d %s\n", unitname(u), i, rtype->_name[0]));
log_warning("%s has %d %s\n", unitname(u), i, rtype->_name[0]);
}
return i;
}

View File

@ -837,8 +837,7 @@ bufunit(const faction * f, const unit * u, int indent, int mode, char *buf,
}
}
if (size <= 1) {
log_warning(("bufunit ran out of space after writing %u bytes.\n",
(bufp - buf)));
log_warning("bufunit ran out of space after writing %u bytes.\n", (bufp - buf));
}
return dh;
}
@ -1548,7 +1547,7 @@ int write_reports(faction * f, time_t ltime)
}
} while (errno);
if (!gotit) {
log_warning(("No report for faction %s!\n", factionid(f)));
log_warning("No report for faction %s!\n", factionid(f));
}
ql_free(ctx.addresses);
seen_done(ctx.seen);

View File

@ -347,7 +347,7 @@ static faction *factionorders(void)
const char *pass = getstrtoken();
if (!checkpasswd(f, (const char *)pass, true)) {
log_warning(("Invalid password for faction %s\n", itoa36(fid)));
log_warning("Invalid password for faction %s\n", itoa36(fid));
ADDMSG(&f->msgs, msg_message("wrongpasswd", "faction password",
f->no, pass));
return 0;
@ -360,7 +360,7 @@ static faction *factionorders(void)
f->lastorders = global.data_turn + 1;
} else {
log_warning(("orders for invalid faction %s\n", itoa36(fid)));
log_warning("orders for invalid faction %s\n", itoa36(fid));
}
return f;
}
@ -806,7 +806,7 @@ unit *read_unit(struct storage *store)
if ((u->flags & UFL_ANON_FACTION) && !rule_stealth_faction()) {
/* if this rule is broken, then fix broken units */
u->flags -= UFL_ANON_FACTION;
log_warning(("%s was anonymous.\n", unitname(u)));
log_warning("%s was anonymous.\n", unitname(u));
}
/* Persistente Befehle einlesen */
free_orders(&u->orders);
@ -823,11 +823,10 @@ unit *read_unit(struct storage *store)
orderp = &ord->next;
ord = NULL;
} else if (p == MAXPERSISTENT) {
log_warning(("%s had %d or more persistent orders\n", unitname(u),
MAXPERSISTENT));
log_warning("%s had %d or more persistent orders\n", unitname(u), MAXPERSISTENT);
}
} else if (n == MAXORDERS) {
log_warning(("%s had %d or more orders\n", unitname(u), MAXORDERS));
log_warning("%s had %d or more orders\n", unitname(u), MAXORDERS);
}
if (ord != NULL)
free_order(ord);
@ -1238,8 +1237,7 @@ faction *readfaction(struct storage * store)
store->r_str_buf(store, email, sizeof(email));
if (set_email(&f->email, email) != 0) {
log_warning(("Invalid email address for faction %s: %s\n", itoa36(f->no),
email));
log_warning("Invalid email address for faction %s: %s\n", itoa36(f->no), email);
set_email(&f->email, "");
}
@ -1412,7 +1410,7 @@ static void repair_unit(unit * u) {
}
if (!found) {
u->race = u->faction->race;
log_warning(("This toad did not have a changerace trigger: %s\n", unitname(u)));
log_warning("This toad did not have a changerace trigger: %s\n", unitname(u));
}
}
}
@ -1454,8 +1452,7 @@ int readgame(const char *filename, int mode, int backup)
char buffer[64];
snprintf(buffer, sizeof(buffer), "%s.xml", game_name);
if (strcmp(basefile, buffer) != 0) {
log_warning(("game mismatch: datafile contains %s, game is %s\n",
basefile, game_name));
log_warning("game mismatch: datafile contains %s, game is %s\n", basefile, game_name);
printf("WARNING: any key to continue, Ctrl-C to stop\n");
getchar();
}
@ -1480,7 +1477,7 @@ int readgame(const char *filename, int mode, int backup)
if (pl == NULL) {
pl = calloc(1, sizeof(plane));
} else {
log_warning(("the plane with id=%d already exists.\n", id));
log_warning("the plane with id=%d already exists.\n", id);
}
pl->id = id;
pl->name = store->r_str(store);
@ -1692,7 +1689,7 @@ int readgame(const char *filename, int mode, int backup)
int no = 666;
while (findfaction(no))
++no;
log_warning(("renum(monsters, %d)\n", no));
log_warning("renum(monsters, %d)\n", no);
renumber_faction(f, no);
}
} else {

View File

@ -63,7 +63,7 @@ spell *find_spell(const char *name)
return sp;
}
}
log_warning(("find_spell: could not find spell '%s'\n", name));
log_warning("find_spell: could not find spell '%s'\n", name);
return 0;
}
@ -121,6 +121,6 @@ spell *find_spellbyid(unsigned int id)
}
}
log_warning(("cannot find spell by id: %u\n", id));
log_warning("cannot find spell by id: %u\n", id);
return NULL;
}

View File

@ -127,7 +127,7 @@ terrain_t oldterrain(const struct terrain_type * terrain)
if (newterrains[t] == terrain)
return t;
}
log_warning(("%s is not a classic terrain.\n", terrain->_name));
log_warning("%s is not a classic terrain.\n", terrain->_name);
return NOTERRAIN;
}

View File

@ -142,14 +142,14 @@ static int txt_open(struct storage *store, const char *filename, int mode)
store->r_tok_buf(store, token, sizeof(token));
if (memcmp(token, utf8_bom, 3) == 0) {
if (enc_gamedata != XML_CHAR_ENCODING_UTF8) {
log_warning(("Found UTF-8 BOM, assuming unicode game data.\n"));
log_warning("Found UTF-8 BOM, assuming unicode game data.\n");
store->encoding = XML_CHAR_ENCODING_UTF8;
}
store->version = atoi(token + 3);
} else {
if (store->encoding == XML_CHAR_ENCODING_NONE) {
store->encoding = XML_CHAR_ENCODING_8859_1;
log_warning(("No BOM, assuming 8859-1 game data.\n"));
log_warning("No BOM, assuming 8859-1 game data.\n");
}
store->version = atoi(token);
}

View File

@ -1562,7 +1562,7 @@ int countheroes(const struct faction *f)
#ifdef DEBUG_MAXHEROES
int m = maxheroes(f);
if (n > m) {
log_warning(("%s has %d of %d heroes\n", factionname(f), n, m));
log_warning("%s has %d of %d heroes\n", factionname(f), n, m);
}
#endif
return n;

View File

@ -604,8 +604,7 @@ static int parse_ships(xmlDocPtr doc)
if (st->coasts[c] != NULL)
++c;
else {
log_warning(("ship %s mentions a non-existing terrain %s.\n",
st->name[0], propValue));
log_warning("ship %s mentions a non-existing terrain %s.\n", st->name[0], propValue);
}
xmlFree(propValue);
}
@ -2210,8 +2209,7 @@ xml_readstrings(xmlXPathContextPtr xpath, xmlNodePtr * nodeTab, int nodeNr,
}
xmlFree(propText);
} else {
log_warning(("string %s has no text in locale %s\n",
zName, locale_name(lang)));
log_warning("string %s has no text in locale %s\n", zName, locale_name(lang));
}
}
xmlXPathFreeObject(result);

View File

@ -78,10 +78,9 @@ static int timeout_read(trigger * t, struct storage *store)
read_triggers(store, &td->triggers);
if (td->timer > 20) {
trigger *tr = td->triggers;
log_warning(("there is a timeout lasting for another %d turns\n",
td->timer));
log_warning("there is a timeout lasting for another %d turns\n", td->timer);
while (tr) {
log_warning((" timeout triggers: %s\n", tr->type->name));
log_warning(" timeout triggers: %s\n", tr->type->name);
tr = tr->next;
}
}

View File

@ -45,14 +45,14 @@ void at_register(attrib_type * at)
attrib_type *find;
if (at->read == NULL) {
log_warning(("registering non-persistent attribute %s.\n", at->name));
log_warning("registering non-persistent attribute %s.\n", at->name);
}
at->hashkey = __at_hashkey(at->name);
find = at_hash[at->hashkey % MAXATHASH];
while (find && at->hashkey != find->hashkey)
find = find->nexthash;
if (find && find == at) {
log_warning(("attribute '%s' was registered more than once\n", at->name));
log_warning("attribute '%s' was registered more than once\n", at->name);
return;
} else {
assert(!find || !"hashkey is already in use");

View File

@ -9,7 +9,7 @@ extern size_t strlcat(char *dst, const char *src, size_t siz);
extern int wrptr(char **ptr, size_t * size, int bytes);
#endif
#define WARN_STATIC_BUFFER() log_warning(("static buffer too small in %s:%d\n", __FILE__, __LINE__))
#define WARN_STATIC_BUFFER() log_warning("static buffer too small in %s:%d\n", __FILE__, __LINE__)
#if !defined(HAVE_STRLPRINTF)
# define HAVE_STRLPRINTF

View File

@ -17,7 +17,7 @@ static char fbuf[MAXLINE];
static void unicode_warning(const char *bp)
{
log_warning(("invalid sequence in UTF-8 string: %s\n", bp));
log_warning("invalid sequence in UTF-8 string: %s\n", bp);
}
INLINE_FUNCTION int eatwhite(const char *ptr, size_t * total_size)

View File

@ -148,8 +148,7 @@ const char *locale_string(const locale * lang, const char *key)
find = find->nexthash;
}
if (!find) {
log_warning(("missing translation for \"%s\" in locale %s\n", key,
lang->name));
log_warning("missing translation for \"%s\" in locale %s\n", key, lang->name);
if (lang != default_locale) {
return locale_string(default_locale, key);
}

View File

@ -196,7 +196,7 @@ void _log_debug(const char *format, ...)
}
}
void _log_warn(const char *format, ...)
void log_warning(const char *format, ...)
{
const char * prefix = "WARNING";
const int mask = LOG_CPWARNING;

View File

@ -19,12 +19,11 @@ extern "C" {
extern void log_close(void);
extern void log_flush(void);
#define log_warning(x) _log_warn x
#define log_error(x) _log_error x
#define log_debug _log_debug
/* use macros above instead of these: */
extern void _log_warn(const char *format, ...);
extern void log_warning(const char *format, ...);
extern void _log_error(const char *format, ...);
extern void _log_debug(const char *format, ...);
extern void log_info(const char *format, ...);

View File

@ -56,12 +56,10 @@ nrmessage_type *nrt_find(const struct locale * lang,
type = type->next;
}
if (!found) {
log_warning(("could not find nr-type %s for locale %s\n",
mtype->name, locale_name(lang)));
log_warning("could not find nr-type %s for locale %s\n", mtype->name, locale_name(lang));
}
if (lang && found && found->lang != lang) {
log_warning(("could not find nr-type %s for locale %s, using %s\n",
mtype->name, locale_name(lang), locale_name(found->lang)));
log_warning("could not find nr-type %s for locale %s, using %s\n", mtype->name, locale_name(lang), locale_name(found->lang));
}
return found;
}

View File

@ -36,7 +36,7 @@ static int eatwhitespace_c(const char **str_p)
} else {
ret = unicode_utf8_to_ucs4(&ucs, str, &len);
if (ret != 0) {
log_warning(("illegal character sequence in UTF8 string: %s\n", str));
log_warning("illegal character sequence in UTF8 string: %s\n", str);
break;
}
if (!iswxspace((wint_t) ucs))
@ -100,8 +100,7 @@ void skip_token(void)
if (ret == 0) {
state->current_token += len;
} else {
log_warning(("illegal character sequence in UTF8 string: %s\n",
state->current_token));
log_warning("illegal character sequence in UTF8 string: %s\n", state->current_token);
}
}
if (iswxspace((wint_t) ucs) && quotechar == 0) {
@ -145,8 +144,7 @@ const char *parse_token(const char **str)
} else {
int ret = unicode_utf8_to_ucs4(&ucs, ctoken, &len);
if (ret != 0) {
log_warning(("illegal character sequence in UTF8 string: %s\n",
ctoken));
log_warning("illegal character sequence in UTF8 string: %s\n", ctoken);
break;
}
}

View File

@ -57,10 +57,10 @@ boolean xml_bvalue(xmlNodePtr node, const char *name, boolean dflt)
else if (strcmp((const char *)propValue, "true") == 0)
result = true;
else if (strcmp((const char *)propValue, "1") == 0) {
log_warning(("boolean value is '1': %s::%s\n", node->name, name));
log_warning("boolean value is '1': %s::%s\n", node->name, name);
result = true;
} else if (strcmp((const char *)propValue, "0") == 0) {
log_warning(("boolean value is '0': %s::%s\n", node->name, name));
log_warning("boolean value is '0': %s::%s\n", node->name, name);
result = false;
}
xmlFree(propValue);