forked from github/server
preview script and logging cleanup
1. all log messages will be terminated with \n, whether the user provided it or not. 2. remove a bunch of print() calls from scripts to reduce clutter 3. replace printf calls with log_* calls to reduce clutter 4. add the new release preview script
This commit is contained in:
parent
130f6401b7
commit
3c2ae7ca93
|
@ -0,0 +1,58 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo "usage: $0 game-id"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
abort() {
|
||||||
|
echo $1
|
||||||
|
[ -z $2 ] && exit -1
|
||||||
|
exit $2 # otherwise
|
||||||
|
}
|
||||||
|
|
||||||
|
[ -d $ERESSEA ] || abort "Invalid env variable ERESSEA ($ERESSEA)"
|
||||||
|
|
||||||
|
GAME=$1
|
||||||
|
LIVE=$ERESSEA/game-$GAME
|
||||||
|
SOURCE=$ERESSEA/git
|
||||||
|
TESTROOT=$LIVE/test
|
||||||
|
REBUILD=0
|
||||||
|
|
||||||
|
[ -d $LIVE ] || usage
|
||||||
|
[ -d $SOURCE ] || abort "missing source directory: $SOURCE"
|
||||||
|
|
||||||
|
[ -f $LIVE/turn ] || abort "missing turn file"
|
||||||
|
let TURN=$(cat $LIVE/turn)-1
|
||||||
|
|
||||||
|
if [ $REBUILD ] ; then
|
||||||
|
cd $SOURCE
|
||||||
|
git pull || abort "failed to update source. do you have local changes?"
|
||||||
|
BUILD=$(grep BUILD src/build.h | awk '{ print $3 }')
|
||||||
|
s/build || abort "build failed."
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "testing turn $TURN of game $GAME with build $BUILD"
|
||||||
|
mkdir -p $TESTROOT
|
||||||
|
cd $TESTROOT
|
||||||
|
|
||||||
|
if [ ! -e eressea.ini ] ; then
|
||||||
|
cat >| eressea.ini <<HEREDOC
|
||||||
|
[lua]
|
||||||
|
dbname = preview.db
|
||||||
|
install = $SOURCE
|
||||||
|
paths = $SOURCE/lunit:$SOURCE/git/scripts
|
||||||
|
rules = e$GAME
|
||||||
|
HEREDOC
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ -d data ] || mkdir data
|
||||||
|
cp $LIVE/eressea.db preview.db
|
||||||
|
ln -f $LIVE/orders.$TURN
|
||||||
|
ln -f $LIVE/data/$TURN.dat data/
|
||||||
|
rm -rf reports
|
||||||
|
mkdir -p reports
|
||||||
|
|
||||||
|
$SOURCE/build-x86_64-gcc-Debug/eressea/eressea -v1 -t$TURN -re$GAME $SOURCE/scripts/run-turn.lua
|
||||||
|
let TURN=$TURN+1
|
||||||
|
[ -e data/$TURN.dat ] || abort "no data file created"
|
|
@ -61,7 +61,6 @@ end
|
||||||
function clean()
|
function clean()
|
||||||
for r in regions() do
|
for r in regions() do
|
||||||
if r.terrain=="ocean" then
|
if r.terrain=="ocean" then
|
||||||
-- print(r)
|
|
||||||
region.destroy(r)
|
region.destroy(r)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
astral = {}
|
astral = {}
|
||||||
|
|
||||||
function astral.update()
|
function astral.update()
|
||||||
print('spawn braineaters')
|
eressea.log.info('spawn braineaters')
|
||||||
spawn_braineaters(0.25)
|
spawn_braineaters(0.25)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
require 'eressea.spells'
|
require 'eressea.spells'
|
||||||
print("rules for game E2")
|
eressea.log.debug("rules for game E2")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
require('eressea'),
|
require('eressea'),
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
require 'eressea.e3.rules'
|
require 'eressea.e3.rules'
|
||||||
require 'eressea.spells'
|
require 'eressea.spells'
|
||||||
print("rules for game E3")
|
|
||||||
|
eressea.log.debug("rules for game E3")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
require('eressea'),
|
require('eressea'),
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
require 'eressea.e3.rules'
|
require 'eressea.e3.rules'
|
||||||
require 'eressea.spells'
|
require 'eressea.spells'
|
||||||
print("rules for game E3")
|
|
||||||
|
eressea.log.debug("rules for game E3")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
require('eressea'),
|
require('eressea'),
|
||||||
|
|
|
@ -5,9 +5,9 @@ require 'eressea.spells'
|
||||||
local self = {}
|
local self = {}
|
||||||
|
|
||||||
function self.update()
|
function self.update()
|
||||||
print('spawn dragons')
|
eressea.log.info('spawn dragons')
|
||||||
spawn_dragons()
|
spawn_dragons()
|
||||||
print('spawn undead')
|
eressea.log.info('spawn undead')
|
||||||
spawn_undead()
|
spawn_undead()
|
||||||
|
|
||||||
update_guards()
|
update_guards()
|
||||||
|
|
|
@ -31,8 +31,8 @@ local function change_locales(localechange)
|
||||||
for index, name in pairs(flist) do
|
for index, name in pairs(flist) do
|
||||||
f = get_faction(atoi36(name))
|
f = get_faction(atoi36(name))
|
||||||
if f ~= nil and f.locale ~= loc then
|
if f ~= nil and f.locale ~= loc then
|
||||||
|
print("LOCALECHANGE ", f, f.locale, loc)
|
||||||
f.locale = loc
|
f.locale = loc
|
||||||
print("LOCALECHANGE ", f, loc)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -40,12 +40,13 @@ end
|
||||||
|
|
||||||
local function dbupdate()
|
local function dbupdate()
|
||||||
update_scores()
|
update_scores()
|
||||||
edb = db.open(config.basepath.."/eressea.db")
|
dbname = config.dbname or 'eressea.db'
|
||||||
|
edb = db.open(config.basepath..'/'..dbname)
|
||||||
if edb~=nil then
|
if edb~=nil then
|
||||||
edb:update_factions()
|
edb:update_factions()
|
||||||
edb:update_scores()
|
edb:update_scores()
|
||||||
else
|
else
|
||||||
eressea.log.error("could not open "..config.basepath.."/eressea.db")
|
eressea.log.error("could not open "..config.basepath..'/'..dbname)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -189,7 +190,6 @@ end
|
||||||
if config.install then
|
if config.install then
|
||||||
confdir = config.install .. '/' .. confdir
|
confdir = config.install .. '/' .. confdir
|
||||||
end
|
end
|
||||||
print(confdir)
|
|
||||||
read_xml(confdir .. 'config.xml', confdir .. 'catalog.xml')
|
read_xml(confdir .. 'config.xml', confdir .. 'catalog.xml')
|
||||||
|
|
||||||
local path = 'scripts'
|
local path = 'scripts'
|
||||||
|
|
|
@ -1180,7 +1180,7 @@ param_t findparam(const char *s, const struct locale * lang)
|
||||||
void **tokens = get_translations(lang, UT_PARAMS);
|
void **tokens = get_translations(lang, UT_PARAMS);
|
||||||
critbit_tree *cb = (critbit_tree *)*tokens;
|
critbit_tree *cb = (critbit_tree *)*tokens;
|
||||||
if (!cb) {
|
if (!cb) {
|
||||||
log_error_n("no parameters defined in locale %s", locale_name(lang));
|
log_error("no parameters defined in locale %s", locale_name(lang));
|
||||||
}
|
}
|
||||||
else if (cb_find_prefix(cb, str, strlen(str), &match, 1, 0)) {
|
else if (cb_find_prefix(cb, str, strlen(str), &match, 1, 0)) {
|
||||||
cb_get_kv(match, &i, sizeof(int));
|
cb_get_kv(match, &i, sizeof(int));
|
||||||
|
@ -1764,7 +1764,7 @@ void init_terrains_translation(const struct locale *lang) {
|
||||||
addtoken(tokens, name, var);
|
addtoken(tokens, name, var);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log_error_n("no translation for terrain %s in locale %s", terrain->_name, locale_name(lang));
|
log_error("no translation for terrain %s in locale %s", terrain->_name, locale_name(lang));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1783,7 +1783,7 @@ void init_options_translation(const struct locale * lang) {
|
||||||
addtoken(tokens, name, var);
|
addtoken(tokens, name, var);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log_error_n("no translation for OPTION %s in locale %s", options[i], locale_name(lang));
|
log_error("no translation for OPTION %s in locale %s", options[i], locale_name(lang));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1818,7 +1818,7 @@ static void init_locale(const struct locale *lang)
|
||||||
addtoken(tokens, name, var);
|
addtoken(tokens, name, var);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log_error_n("no translation for magic school %s in locale %s", tok, locale_name(lang));
|
log_error("no translation for magic school %s in locale %s", tok, locale_name(lang));
|
||||||
}
|
}
|
||||||
tok = strtok(NULL, " ");
|
tok = strtok(NULL, " ");
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,7 @@ static void json_maintenance_i(cJSON *json, maintenance *mt) {
|
||||||
mt->number = child->valueint;
|
mt->number = child->valueint;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log_error_n("maintenance contains unknown attribute %s", child->string);
|
log_error("maintenance contains unknown attribute %s", child->string);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case cJSON_String:
|
case cJSON_String:
|
||||||
|
@ -97,7 +97,7 @@ static void json_maintenance_i(cJSON *json, maintenance *mt) {
|
||||||
mt->rtype = rt_get_or_create(child->valuestring);
|
mt->rtype = rt_get_or_create(child->valuestring);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log_error_n("maintenance contains unknown attribute %s", child->string);
|
log_error("maintenance contains unknown attribute %s", child->string);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case cJSON_Array:
|
case cJSON_Array:
|
||||||
|
@ -106,11 +106,11 @@ static void json_maintenance_i(cJSON *json, maintenance *mt) {
|
||||||
mt->flags = json_flags(child, flags);
|
mt->flags = json_flags(child, flags);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log_error_n("maintenance contains unknown array %s", child->string);
|
log_error("maintenance contains unknown array %s", child->string);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
log_error_n("maintenance contains unknown attribute %s", child->string);
|
log_error("maintenance contains unknown attribute %s", child->string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ static void json_maintenance(cJSON *json, maintenance **mtp) {
|
||||||
size = cJSON_GetArraySize(json);
|
size = cJSON_GetArraySize(json);
|
||||||
}
|
}
|
||||||
else if (json->type != cJSON_Object) {
|
else if (json->type != cJSON_Object) {
|
||||||
log_error_n("maintenance is not a json object or array (%d)", json->type);
|
log_error("maintenance is not a json object or array (%d)", json->type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
*mtp = mt = (struct maintenance *) calloc(sizeof(struct maintenance), size + 1);
|
*mtp = mt = (struct maintenance *) calloc(sizeof(struct maintenance), size + 1);
|
||||||
|
@ -155,7 +155,7 @@ static void json_construction(cJSON *json, construction **consp) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (json->type != cJSON_Object) {
|
if (json->type != cJSON_Object) {
|
||||||
log_error_n("building %s is not a json object: %d", json->string, json->type);
|
log_error("building %s is not a json object: %d", json->string, json->type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
construction * cons = (construction *)calloc(sizeof(construction), 1);
|
construction * cons = (construction *)calloc(sizeof(construction), 1);
|
||||||
|
@ -178,7 +178,7 @@ static void json_construction(cJSON *json, construction **consp) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
log_error_n("building %s contains unknown attribute %s", json->string, child->string);
|
log_error("building %s contains unknown attribute %s", json->string, child->string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*consp = cons;
|
*consp = cons;
|
||||||
|
@ -187,7 +187,7 @@ static void json_construction(cJSON *json, construction **consp) {
|
||||||
static void json_terrain(cJSON *json, terrain_type *ter) {
|
static void json_terrain(cJSON *json, terrain_type *ter) {
|
||||||
cJSON *child;
|
cJSON *child;
|
||||||
if (json->type!=cJSON_Object) {
|
if (json->type!=cJSON_Object) {
|
||||||
log_error_n("terrain %s is not a json object: %d", json->string, json->type);
|
log_error("terrain %s is not a json object: %d", json->string, json->type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (child=json->child;child;child=child->next) {
|
for (child=json->child;child;child=child->next) {
|
||||||
|
@ -199,11 +199,11 @@ static void json_terrain(cJSON *json, terrain_type *ter) {
|
||||||
};
|
};
|
||||||
ter->flags = json_flags(child, flags);
|
ter->flags = json_flags(child, flags);
|
||||||
} else {
|
} else {
|
||||||
log_error_n("terrain %s contains unknown attribute %s", json->string, child->string);
|
log_error("terrain %s contains unknown attribute %s", json->string, child->string);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
log_error_n("terrain %s contains unknown attribute %s", json->string, child->string);
|
log_error("terrain %s contains unknown attribute %s", json->string, child->string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -214,7 +214,7 @@ static void json_building(cJSON *json, building_type *bt) {
|
||||||
"nodestroy", "nobuild", "unique", "decay", "dynamic", "magic", "oneperturn", "namechange", 0
|
"nodestroy", "nobuild", "unique", "decay", "dynamic", "magic", "oneperturn", "namechange", 0
|
||||||
};
|
};
|
||||||
if (json->type != cJSON_Object) {
|
if (json->type != cJSON_Object) {
|
||||||
log_error_n("building %s is not a json object: %d", json->string, json->type);
|
log_error("building %s is not a json object: %d", json->string, json->type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (child=json->child;child;child=child->next) {
|
for (child=json->child;child;child=child->next) {
|
||||||
|
@ -244,10 +244,10 @@ static void json_building(cJSON *json, building_type *bt) {
|
||||||
const struct building *, int))get_function(child->valuestring);
|
const struct building *, int))get_function(child->valuestring);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
log_error_n("building %s contains unknown attribute %s", json->string, child->string);
|
log_error("building %s contains unknown attribute %s", json->string, child->string);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
log_error_n("building %s contains unknown attribute %s", json->string, child->string);
|
log_error("building %s contains unknown attribute %s", json->string, child->string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -258,7 +258,7 @@ static void json_item(cJSON *json, item_type *itype) {
|
||||||
"herb", "cursed", "nodrop", "big", "animal", "vehicle", 0
|
"herb", "cursed", "nodrop", "big", "animal", "vehicle", 0
|
||||||
};
|
};
|
||||||
if (json->type!=cJSON_Object) {
|
if (json->type!=cJSON_Object) {
|
||||||
log_error_n("ship %s is not a json object: %d", json->string, json->type);
|
log_error("ship %s is not a json object: %d", json->string, json->type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (child=json->child;child;child=child->next) {
|
for (child=json->child;child;child=child->next) {
|
||||||
|
@ -272,17 +272,17 @@ static void json_item(cJSON *json, item_type *itype) {
|
||||||
itype->capacity = child->valueint;
|
itype->capacity = child->valueint;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
log_error_n("item %s contains unknown attribute %s", json->string, child->string);
|
log_error("item %s contains unknown attribute %s", json->string, child->string);
|
||||||
break;
|
break;
|
||||||
case cJSON_Array:
|
case cJSON_Array:
|
||||||
if (strcmp(child->string, "flags")==0) {
|
if (strcmp(child->string, "flags")==0) {
|
||||||
itype->flags = json_flags(child, flags);
|
itype->flags = json_flags(child, flags);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
log_error_n("item %s contains unknown attribute %s", json->string, child->string);
|
log_error("item %s contains unknown attribute %s", json->string, child->string);
|
||||||
case cJSON_Object:
|
case cJSON_Object:
|
||||||
default:
|
default:
|
||||||
log_error_n("item %s contains unknown attribute %s", json->string, child->string);
|
log_error("item %s contains unknown attribute %s", json->string, child->string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -290,7 +290,7 @@ static void json_item(cJSON *json, item_type *itype) {
|
||||||
static void json_ship(cJSON *json, ship_type *st) {
|
static void json_ship(cJSON *json, ship_type *st) {
|
||||||
cJSON *child, *iter;
|
cJSON *child, *iter;
|
||||||
if (json->type!=cJSON_Object) {
|
if (json->type!=cJSON_Object) {
|
||||||
log_error_n("ship %s is not a json object: %d", json->string, json->type);
|
log_error("ship %s is not a json object: %d", json->string, json->type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (child=json->child;child;child=child->next) {
|
for (child=json->child;child;child=child->next) {
|
||||||
|
@ -300,7 +300,7 @@ static void json_ship(cJSON *json, ship_type *st) {
|
||||||
if (strcmp(child->string, "construction")==0) {
|
if (strcmp(child->string, "construction")==0) {
|
||||||
json_construction(child, &st->construction);
|
json_construction(child, &st->construction);
|
||||||
} else {
|
} else {
|
||||||
log_error_n("ship %s contains unknown attribute %s", json->string, child->string);
|
log_error("ship %s contains unknown attribute %s", json->string, child->string);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case cJSON_Array:
|
case cJSON_Array:
|
||||||
|
@ -320,11 +320,11 @@ static void json_ship(cJSON *json, ship_type *st) {
|
||||||
if (strcmp(child->string, "range")==0) {
|
if (strcmp(child->string, "range")==0) {
|
||||||
st->range = child->valueint;
|
st->range = child->valueint;
|
||||||
} else {
|
} else {
|
||||||
log_error_n("ship %s contains unknown attribute %s", json->string, child->string);
|
log_error("ship %s contains unknown attribute %s", json->string, child->string);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
log_error_n("ship %s contains unknown attribute %s", json->string, child->string);
|
log_error("ship %s contains unknown attribute %s", json->string, child->string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -345,7 +345,7 @@ static void json_race(cJSON *json, race *rc) {
|
||||||
"giveunit", "getitem", 0
|
"giveunit", "getitem", 0
|
||||||
};
|
};
|
||||||
if (json->type != cJSON_Object) {
|
if (json->type != cJSON_Object) {
|
||||||
log_error_n("race %s is not a json object: %d", json->string, json->type);
|
log_error("race %s is not a json object: %d", json->string, json->type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (child=json->child;child;child=child->next) {
|
for (child=json->child;child;child=child->next) {
|
||||||
|
@ -401,7 +401,7 @@ static void json_race(cJSON *json, race *rc) {
|
||||||
static void json_terrains(cJSON *json) {
|
static void json_terrains(cJSON *json) {
|
||||||
cJSON *child;
|
cJSON *child;
|
||||||
if (json->type!=cJSON_Object) {
|
if (json->type!=cJSON_Object) {
|
||||||
log_error_n("terrains is not a json object: %d", json->type);
|
log_error("terrains is not a json object: %d", json->type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (child=json->child;child;child=child->next) {
|
for (child=json->child;child;child=child->next) {
|
||||||
|
@ -412,7 +412,7 @@ static void json_terrains(cJSON *json) {
|
||||||
static void json_buildings(cJSON *json) {
|
static void json_buildings(cJSON *json) {
|
||||||
cJSON *child;
|
cJSON *child;
|
||||||
if (json->type!=cJSON_Object) {
|
if (json->type!=cJSON_Object) {
|
||||||
log_error_n("buildings is not a json object: %d", json->type);
|
log_error("buildings is not a json object: %d", json->type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (child=json->child;child;child=child->next) {
|
for (child=json->child;child;child=child->next) {
|
||||||
|
@ -423,7 +423,7 @@ static void json_buildings(cJSON *json) {
|
||||||
static void json_spells(cJSON *json) {
|
static void json_spells(cJSON *json) {
|
||||||
cJSON *child;
|
cJSON *child;
|
||||||
if (json->type != cJSON_Object) {
|
if (json->type != cJSON_Object) {
|
||||||
log_error_n("spells is not a json object: %d", json->type);
|
log_error("spells is not a json object: %d", json->type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (child = json->child; child; child = child->next) {
|
for (child = json->child; child; child = child->next) {
|
||||||
|
@ -452,7 +452,7 @@ static void json_spells(cJSON *json) {
|
||||||
static void json_items(cJSON *json) {
|
static void json_items(cJSON *json) {
|
||||||
cJSON *child;
|
cJSON *child;
|
||||||
if (json->type!=cJSON_Object) {
|
if (json->type!=cJSON_Object) {
|
||||||
log_error_n("items is not a json object: %d", json->type);
|
log_error("items is not a json object: %d", json->type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (child=json->child;child;child=child->next) {
|
for (child=json->child;child;child=child->next) {
|
||||||
|
@ -468,7 +468,7 @@ static void json_items(cJSON *json) {
|
||||||
static void json_ships(cJSON *json) {
|
static void json_ships(cJSON *json) {
|
||||||
cJSON *child;
|
cJSON *child;
|
||||||
if (json->type!=cJSON_Object) {
|
if (json->type!=cJSON_Object) {
|
||||||
log_error_n("ships is not a json object: %d", json->type);
|
log_error("ships is not a json object: %d", json->type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (child=json->child;child;child=child->next) {
|
for (child=json->child;child;child=child->next) {
|
||||||
|
@ -479,7 +479,7 @@ static void json_ships(cJSON *json) {
|
||||||
static void json_locale(cJSON *json, struct locale *lang) {
|
static void json_locale(cJSON *json, struct locale *lang) {
|
||||||
cJSON *child;
|
cJSON *child;
|
||||||
if (json->type!=cJSON_Object) {
|
if (json->type!=cJSON_Object) {
|
||||||
log_error_n("strings is not a json object: %d", json->type);
|
log_error("strings is not a json object: %d", json->type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (child=json->child;child;child=child->next) {
|
for (child=json->child;child;child=child->next) {
|
||||||
|
@ -492,7 +492,7 @@ static void json_locale(cJSON *json, struct locale *lang) {
|
||||||
static void json_strings(cJSON *json) {
|
static void json_strings(cJSON *json) {
|
||||||
cJSON *child;
|
cJSON *child;
|
||||||
if (json->type!=cJSON_Object) {
|
if (json->type!=cJSON_Object) {
|
||||||
log_error_n("strings is not a json object: %d", json->type);
|
log_error("strings is not a json object: %d", json->type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (child=json->child;child;child=child->next) {
|
for (child=json->child;child;child=child->next) {
|
||||||
|
@ -500,7 +500,7 @@ static void json_strings(cJSON *json) {
|
||||||
struct locale *lang = get_or_create_locale(child->string);
|
struct locale *lang = get_or_create_locale(child->string);
|
||||||
json_locale(child, lang);
|
json_locale(child, lang);
|
||||||
} else {
|
} else {
|
||||||
log_error_n("strings for locale `%s` are not a json object: %d", child->string, child->type);
|
log_error("strings for locale `%s` are not a json object: %d", child->string, child->type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -508,7 +508,7 @@ static void json_strings(cJSON *json) {
|
||||||
static void json_direction(cJSON *json, struct locale *lang) {
|
static void json_direction(cJSON *json, struct locale *lang) {
|
||||||
cJSON *child;
|
cJSON *child;
|
||||||
if (json->type!=cJSON_Object) {
|
if (json->type!=cJSON_Object) {
|
||||||
log_error_n("directions for locale `%s` not a json object: %d", locale_name(lang), json->type);
|
log_error("directions for locale `%s` not a json object: %d", locale_name(lang), json->type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (child=json->child;child;child=child->next) {
|
for (child=json->child;child;child=child->next) {
|
||||||
|
@ -523,7 +523,7 @@ static void json_direction(cJSON *json, struct locale *lang) {
|
||||||
init_direction(lang, dir, entry->valuestring);
|
init_direction(lang, dir, entry->valuestring);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log_error_n("invalid type %d for direction `%s`", child->type, child->string);
|
log_error("invalid type %d for direction `%s`", child->type, child->string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -532,7 +532,7 @@ static void json_direction(cJSON *json, struct locale *lang) {
|
||||||
static void json_directions(cJSON *json) {
|
static void json_directions(cJSON *json) {
|
||||||
cJSON *child;
|
cJSON *child;
|
||||||
if (json->type!=cJSON_Object) {
|
if (json->type!=cJSON_Object) {
|
||||||
log_error_n("directions is not a json object: %d", json->type);
|
log_error("directions is not a json object: %d", json->type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (child=json->child;child;child=child->next) {
|
for (child=json->child;child;child=child->next) {
|
||||||
|
@ -544,7 +544,7 @@ static void json_directions(cJSON *json) {
|
||||||
static void json_skill(cJSON *json, struct locale *lang) {
|
static void json_skill(cJSON *json, struct locale *lang) {
|
||||||
cJSON *child;
|
cJSON *child;
|
||||||
if (json->type!=cJSON_Object) {
|
if (json->type!=cJSON_Object) {
|
||||||
log_error_n("skill for locale `%s` not a json object: %d", locale_name(lang), json->type);
|
log_error("skill for locale `%s` not a json object: %d", locale_name(lang), json->type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (child=json->child;child;child=child->next) {
|
for (child=json->child;child;child=child->next) {
|
||||||
|
@ -563,10 +563,10 @@ static void json_skill(cJSON *json, struct locale *lang) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log_error_n("invalid type %d for skill `%s`", child->type, child->string);
|
log_error("invalid type %d for skill `%s`", child->type, child->string);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log_error_n("unknown skill `%s` for locale `%s`", child->string, locale_name(lang));
|
log_error("unknown skill `%s` for locale `%s`", child->string, locale_name(lang));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -574,7 +574,7 @@ static void json_skill(cJSON *json, struct locale *lang) {
|
||||||
static void json_keyword(cJSON *json, struct locale *lang) {
|
static void json_keyword(cJSON *json, struct locale *lang) {
|
||||||
cJSON *child;
|
cJSON *child;
|
||||||
if (json->type!=cJSON_Object) {
|
if (json->type!=cJSON_Object) {
|
||||||
log_error_n("keywords for locale `%s` not a json object: %d", locale_name(lang), json->type);
|
log_error("keywords for locale `%s` not a json object: %d", locale_name(lang), json->type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (child=json->child;child;child=child->next) {
|
for (child=json->child;child;child=child->next) {
|
||||||
|
@ -593,10 +593,10 @@ static void json_keyword(cJSON *json, struct locale *lang) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log_error_n("invalid type %d for keyword `%s`", child->type, child->string);
|
log_error("invalid type %d for keyword `%s`", child->type, child->string);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log_error_n("unknown keyword `%s` for locale `%s`", child->string, locale_name(lang));
|
log_error("unknown keyword `%s` for locale `%s`", child->string, locale_name(lang));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -604,7 +604,7 @@ static void json_keyword(cJSON *json, struct locale *lang) {
|
||||||
static void json_skills(cJSON *json) {
|
static void json_skills(cJSON *json) {
|
||||||
cJSON *child;
|
cJSON *child;
|
||||||
if (json->type!=cJSON_Object) {
|
if (json->type!=cJSON_Object) {
|
||||||
log_error_n("skills is not a json object: %d", json->type);
|
log_error("skills is not a json object: %d", json->type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (child=json->child;child;child=child->next) {
|
for (child=json->child;child;child=child->next) {
|
||||||
|
@ -616,7 +616,7 @@ static void json_skills(cJSON *json) {
|
||||||
static void json_keywords(cJSON *json) {
|
static void json_keywords(cJSON *json) {
|
||||||
cJSON *child;
|
cJSON *child;
|
||||||
if (json->type!=cJSON_Object) {
|
if (json->type!=cJSON_Object) {
|
||||||
log_error_n("keywords is not a json object: %d", json->type);
|
log_error("keywords is not a json object: %d", json->type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (child=json->child;child;child=child->next) {
|
for (child=json->child;child;child=child->next) {
|
||||||
|
@ -628,7 +628,7 @@ static void json_keywords(cJSON *json) {
|
||||||
static void json_races(cJSON *json) {
|
static void json_races(cJSON *json) {
|
||||||
cJSON *child;
|
cJSON *child;
|
||||||
if (json->type!=cJSON_Object) {
|
if (json->type!=cJSON_Object) {
|
||||||
log_error_n("races is not a json object: %d", json->type);
|
log_error("races is not a json object: %d", json->type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (child=json->child;child;child=child->next) {
|
for (child=json->child;child;child=child->next) {
|
||||||
|
@ -639,7 +639,7 @@ static void json_races(cJSON *json) {
|
||||||
void json_config(cJSON *json) {
|
void json_config(cJSON *json) {
|
||||||
cJSON *child;
|
cJSON *child;
|
||||||
if (json->type!=cJSON_Object) {
|
if (json->type!=cJSON_Object) {
|
||||||
log_error_n("config is not a json object: %d", json->type);
|
log_error("config is not a json object: %d", json->type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (child=json->child;child;child=child->next) {
|
for (child=json->child;child;child=child->next) {
|
||||||
|
@ -673,7 +673,7 @@ void json_config(cJSON *json) {
|
||||||
else if (strcmp(child->string, "terrains") == 0) {
|
else if (strcmp(child->string, "terrains") == 0) {
|
||||||
json_terrains(child);
|
json_terrains(child);
|
||||||
} else {
|
} else {
|
||||||
log_error_n("config contains unknown attribute %s", child->string);
|
log_error("config contains unknown attribute %s", child->string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
init_locales();
|
init_locales();
|
||||||
|
|
|
@ -1618,19 +1618,17 @@ int write_reports(faction * f, time_t ltime)
|
||||||
|
|
||||||
if (errno) {
|
if (errno) {
|
||||||
char zText[64];
|
char zText[64];
|
||||||
puts(" ERROR");
|
log_warning("retrying, error %d during reports for faction %s", errno, factionname(f));
|
||||||
sprintf(zText, "Waiting %u seconds before we retry", backup/1000);
|
sprintf(zText, "waiting %u seconds before we retry", backup/1000);
|
||||||
perror(zText);
|
perror(zText);
|
||||||
_sleep(backup);
|
_sleep(backup);
|
||||||
if (backup < maxbackup) {
|
if (backup < maxbackup) {
|
||||||
backup *= 2;
|
backup *= 2;
|
||||||
}
|
}
|
||||||
} else if (verbosity >= 2) {
|
|
||||||
puts(" DONE");
|
|
||||||
}
|
}
|
||||||
} while (errno);
|
} while (errno);
|
||||||
if (!gotit) {
|
if (!gotit) {
|
||||||
log_warning("No report for faction %s!\n", factionid(f));
|
log_warning("No report for faction %s!", factionid(f));
|
||||||
}
|
}
|
||||||
ql_free(ctx.addresses);
|
ql_free(ctx.addresses);
|
||||||
seen_done(ctx.seen);
|
seen_done(ctx.seen);
|
||||||
|
|
|
@ -263,8 +263,7 @@ int readorders(const char *filename)
|
||||||
perror(filename);
|
perror(filename);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (verbosity >= 1)
|
log_info("reading orders from %s", filename);
|
||||||
puts(" - lese Befehlsdatei...\n");
|
|
||||||
|
|
||||||
/* TODO: recognize UTF8 BOM */
|
/* TODO: recognize UTF8 BOM */
|
||||||
b = getbuf(F, enc_gamedata);
|
b = getbuf(F, enc_gamedata);
|
||||||
|
@ -333,9 +332,7 @@ int readorders(const char *filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(F);
|
fclose(F);
|
||||||
if (verbosity >= 1)
|
log_info("done reading orders for %d factions", nfactions);
|
||||||
puts("\n");
|
|
||||||
log_printf(stdout, " %d Befehlsdateien gelesen\n", nfactions);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ $#include <util/log.h>
|
||||||
|
|
||||||
module eressea {
|
module eressea {
|
||||||
module log {
|
module log {
|
||||||
void log_error_n @ error(const char *message);
|
void log_error @ error(const char *message);
|
||||||
void log_debug @ debug(const char *message);
|
void log_debug @ debug(const char *message);
|
||||||
void log_warning @ warning(const char *message);
|
void log_warning @ warning(const char *message);
|
||||||
void log_info @ info(const char *message);
|
void log_info @ info(const char *message);
|
||||||
|
|
|
@ -25,7 +25,7 @@ static void tolua_reg_types (lua_State* tolua_S)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/* function: log_error_n */
|
/* function: log_error */
|
||||||
static int tolua_log_eressea_log_error00(lua_State* tolua_S)
|
static int tolua_log_eressea_log_error00(lua_State* tolua_S)
|
||||||
{
|
{
|
||||||
#ifndef TOLUA_RELEASE
|
#ifndef TOLUA_RELEASE
|
||||||
|
@ -40,7 +40,7 @@ static int tolua_log_eressea_log_error00(lua_State* tolua_S)
|
||||||
{
|
{
|
||||||
const char* message = ((const char*) tolua_tostring(tolua_S,1,0));
|
const char* message = ((const char*) tolua_tostring(tolua_S,1,0));
|
||||||
{
|
{
|
||||||
log_error_n(message);
|
log_error(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include <util/base36.h>
|
#include <util/base36.h>
|
||||||
#include <util/language.h>
|
#include <util/language.h>
|
||||||
#include <util/lists.h>
|
#include <util/lists.h>
|
||||||
|
#include <util/log.h>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -160,7 +161,7 @@ void report_summary(summary * s, summary * o, bool full)
|
||||||
fwrite(utf8_bom, 1, 3, F);
|
fwrite(utf8_bom, 1, 3, F);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
printf("Schreibe Zusammenfassung (parteien)...\n");
|
log_info("writing summary to file: parteien.\n");
|
||||||
fprintf(F, "%s\n%s\n\n", game_name(), gamedate2(default_locale));
|
fprintf(F, "%s\n%s\n\n", game_name(), gamedate2(default_locale));
|
||||||
fprintf(F, "Auswertung Nr: %d\n\n", turn);
|
fprintf(F, "Auswertung Nr: %d\n\n", turn);
|
||||||
fprintf(F, "Parteien: %s\n", pcomp(s->factions, o->factions));
|
fprintf(F, "Parteien: %s\n", pcomp(s->factions, o->factions));
|
||||||
|
@ -303,7 +304,7 @@ void report_summary(summary * s, summary * o, bool full)
|
||||||
fclose(F);
|
fclose(F);
|
||||||
|
|
||||||
if (full) {
|
if (full) {
|
||||||
printf("writing date & turn\n");
|
log_info("writing date & turn\n");
|
||||||
writeturn();
|
writeturn();
|
||||||
}
|
}
|
||||||
free(nmrs);
|
free(nmrs);
|
||||||
|
|
|
@ -169,6 +169,14 @@ static void _log_write(FILE * stream, int codepage, const char * prefix, const c
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void _log_writeln(FILE * stream, int codepage, const char * prefix, const char *format, va_list args)
|
||||||
|
{
|
||||||
|
size_t len = strlen(format);
|
||||||
|
_log_write(stream, codepage, prefix, format, args);
|
||||||
|
if (format[len-1]!='\n') {
|
||||||
|
fputc('\n', stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
void log_debug(const char *format, ...)
|
void log_debug(const char *format, ...)
|
||||||
{
|
{
|
||||||
const char * prefix = "DEBUG";
|
const char * prefix = "DEBUG";
|
||||||
|
@ -178,7 +186,7 @@ void log_debug(const char *format, ...)
|
||||||
if (logfile && (log_flags & mask)) {
|
if (logfile && (log_flags & mask)) {
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
_log_write(logfile, 0, prefix, format, args);
|
_log_writeln(logfile, 0, prefix, format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,7 +196,7 @@ void log_debug(const char *format, ...)
|
||||||
if (!dupe) {
|
if (!dupe) {
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
_log_write(stderr, stdio_codepage, prefix, format, args);
|
_log_writeln(stderr, stdio_codepage, prefix, format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -206,7 +214,7 @@ void log_warning(const char *format, ...)
|
||||||
if (logfile && (log_flags & mask)) {
|
if (logfile && (log_flags & mask)) {
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
_log_write(logfile, 0, prefix, format, args);
|
_log_writeln(logfile, 0, prefix, format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,37 +224,7 @@ void log_warning(const char *format, ...)
|
||||||
if (!dupe) {
|
if (!dupe) {
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
_log_write(stderr, stdio_codepage, prefix, format, args);
|
_log_writeln(stderr, stdio_codepage, prefix, format, args);
|
||||||
va_end(args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (log_flags & LOG_FLUSH) {
|
|
||||||
log_flush();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void log_error_n(const char *format, ...)
|
|
||||||
{
|
|
||||||
const char * prefix = "ERROR";
|
|
||||||
const int mask = LOG_CPERROR;
|
|
||||||
|
|
||||||
/* write to the logfile, always */
|
|
||||||
if (logfile && (log_flags & mask)) {
|
|
||||||
va_list args;
|
|
||||||
va_start(args, format);
|
|
||||||
_log_write(logfile, 0, prefix, format, args);
|
|
||||||
fputc('\n', logfile);
|
|
||||||
va_end(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* write to stderr, if that's not the logfile already */
|
|
||||||
if (logfile!=stderr && (log_stderr & mask)) {
|
|
||||||
int dupe = check_dupe(format, prefix);
|
|
||||||
if (!dupe) {
|
|
||||||
va_list args;
|
|
||||||
va_start(args, format);
|
|
||||||
_log_write(stderr, stdio_codepage, prefix, format, args);
|
|
||||||
fputc('\n', stderr);
|
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -264,7 +242,7 @@ void log_error(const char *format, ...)
|
||||||
if (logfile && (log_flags & mask)) {
|
if (logfile && (log_flags & mask)) {
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
_log_write(logfile, 0, prefix, format, args);
|
_log_writeln(logfile, 0, prefix, format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,7 +252,7 @@ void log_error(const char *format, ...)
|
||||||
if (!dupe) {
|
if (!dupe) {
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
_log_write(stderr, stdio_codepage, prefix, format, args);
|
_log_writeln(stderr, stdio_codepage, prefix, format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -292,7 +270,7 @@ void log_info(const char *format, ...)
|
||||||
if (logfile && (log_flags & mask)) {
|
if (logfile && (log_flags & mask)) {
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
_log_write(logfile, 0, prefix, format, args);
|
_log_writeln(logfile, 0, prefix, format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,7 +280,7 @@ void log_info(const char *format, ...)
|
||||||
if (!dupe) {
|
if (!dupe) {
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
_log_write(stderr, stdio_codepage, prefix, format, args);
|
_log_writeln(stderr, stdio_codepage, prefix, format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ extern "C" {
|
||||||
/* use macros above instead of these: */
|
/* use macros above instead of these: */
|
||||||
extern void log_warning(const char *format, ...);
|
extern void log_warning(const char *format, ...);
|
||||||
extern void log_error(const char *format, ...);
|
extern void log_error(const char *format, ...);
|
||||||
extern void log_error_n(const char *format, ...);
|
|
||||||
extern void log_debug(const char *format, ...);
|
extern void log_debug(const char *format, ...);
|
||||||
extern void log_info(const char *format, ...);
|
extern void log_info(const char *format, ...);
|
||||||
extern void log_printf(FILE * ios, const char *format, ...);
|
extern void log_printf(FILE * ios, const char *format, ...);
|
||||||
|
|
Loading…
Reference in New Issue