forked from github/server
logfiles implementiert und mit einbau begonnen
This commit is contained in:
parent
4a1c6862cd
commit
92c3d3f8be
|
@ -1,6 +1,6 @@
|
||||||
/* vi: set ts=2:
|
/* vi: set ts=2:
|
||||||
*
|
*
|
||||||
* $Id: laws.c,v 1.19 2001/02/11 20:54:01 enno Exp $
|
* $Id: laws.c,v 1.20 2001/02/12 22:39:56 enno Exp $
|
||||||
* Eressea PB(E)M host Copyright (C) 1998-2000
|
* Eressea PB(E)M host Copyright (C) 1998-2000
|
||||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||||
|
@ -2142,7 +2142,7 @@ reorder_owners(region * r)
|
||||||
assert(!u->building);
|
assert(!u->building);
|
||||||
if (u->ship==NULL) {
|
if (u->ship==NULL) {
|
||||||
if (fval(u, FL_OWNER)) {
|
if (fval(u, FL_OWNER)) {
|
||||||
fprintf(stderr, "WARNING: Einheit %s war Besitzer von nichts.\n", unitname(u));
|
log_warning(("[reorder_owners] Einheit %s war Besitzer von nichts.\n", unitname(u)));
|
||||||
freset(u, FL_OWNER);
|
freset(u, FL_OWNER);
|
||||||
}
|
}
|
||||||
if (useek!=up) {
|
if (useek!=up) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* vi: set ts=2:
|
/* vi: set ts=2:
|
||||||
*
|
*
|
||||||
* $Id: border.c,v 1.4 2001/02/10 10:40:11 enno Exp $
|
* $Id: border.c,v 1.5 2001/02/12 22:39:56 enno Exp $
|
||||||
* Eressea PB(E)M host Copyright (C) 1998-2000
|
* Eressea PB(E)M host Copyright (C) 1998-2000
|
||||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||||
|
@ -117,7 +117,7 @@ read_borders(FILE * f)
|
||||||
if (to==from) {
|
if (to==from) {
|
||||||
direction_t dir = (direction_t) (rand() % MAXDIRECTIONS);
|
direction_t dir = (direction_t) (rand() % MAXDIRECTIONS);
|
||||||
region * r = rconnect(from, dir);
|
region * r = rconnect(from, dir);
|
||||||
fprintf(stderr, "WARNING: invalid %s in %s\n", type->__name, tregionid(from, NULL));
|
log_error(("[read_borders] invalid %s in %s\n", type->__name, tregionid(from, NULL)));
|
||||||
if (r!=NULL) to = r;
|
if (r!=NULL) to = r;
|
||||||
}
|
}
|
||||||
b = new_border(type, from, to);
|
b = new_border(type, from, to);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* vi: set ts=2:
|
/* vi: set ts=2:
|
||||||
*
|
*
|
||||||
* $Id: eressea.c,v 1.12 2001/02/10 14:18:00 enno Exp $
|
* $Id: eressea.c,v 1.13 2001/02/12 22:39:56 enno Exp $
|
||||||
* Eressea PB(E)M host Copyright (C) 1998-2000
|
* Eressea PB(E)M host Copyright (C) 1998-2000
|
||||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||||
|
@ -915,8 +915,8 @@ strcheck (const char *s, size_t maxlen)
|
||||||
static char buffer[16 * 1024];
|
static char buffer[16 * 1024];
|
||||||
if (strlen(s) > maxlen) {
|
if (strlen(s) > maxlen) {
|
||||||
assert(maxlen < 16 * 1024);
|
assert(maxlen < 16 * 1024);
|
||||||
fprintf(stderr, "\nWARNUNG: String wurde auf %d Zeichen verkürzt:\n%s\n",
|
log_warning(("[strcheck] String wurde auf %d Zeichen verkürzt:\n%s\n",
|
||||||
(int)maxlen, s);
|
(int)maxlen, s));
|
||||||
strncpy(buffer, s, maxlen);
|
strncpy(buffer, s, maxlen);
|
||||||
buffer[maxlen] = 0;
|
buffer[maxlen] = 0;
|
||||||
return buffer;
|
return buffer;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* vi: set ts=2:
|
/* vi: set ts=2:
|
||||||
*
|
*
|
||||||
* $Id: eressea.h,v 1.16 2001/02/10 19:24:05 enno Exp $
|
* $Id: eressea.h,v 1.17 2001/02/12 22:39:56 enno Exp $
|
||||||
* Eressea PB(E)M host Copyright (C) 1998-2000
|
* Eressea PB(E)M host Copyright (C) 1998-2000
|
||||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||||
|
@ -1128,6 +1128,8 @@ extern void kernel_done(void);
|
||||||
|
|
||||||
#define FIRST_TURN 184
|
#define FIRST_TURN 184
|
||||||
|
|
||||||
|
#include <log.h>
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#include <stdafx.h>
|
#include <stdafx.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* vi: set ts=2:
|
/* vi: set ts=2:
|
||||||
*
|
*
|
||||||
* $Id: magic.c,v 1.6 2001/02/09 13:53:51 corwin Exp $
|
* $Id: magic.c,v 1.7 2001/02/12 22:39:56 enno Exp $
|
||||||
* Eressea PB(E)M host Copyright (C) 1998-2000
|
* Eressea PB(E)M host Copyright (C) 1998-2000
|
||||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||||
|
@ -2414,7 +2414,7 @@ sm_familiar(const unit * u, const region * r, skill_t sk, int value) /* skillmod
|
||||||
int mod;
|
int mod;
|
||||||
unit * familiar = get_familiar(u);
|
unit * familiar = get_familiar(u);
|
||||||
if (familiar==NULL) {
|
if (familiar==NULL) {
|
||||||
fprintf(stderr, "WARNING: %s has a familiar-skillmod, but no familiar\n", unitname(u));
|
log_error(("[sm_familiar] %s has a familiar-skillmod, but no familiar\n", unitname(u)));
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
mod = eff_skill(familiar, sk, r)/2;
|
mod = eff_skill(familiar, sk, r)/2;
|
||||||
|
|
|
@ -0,0 +1,86 @@
|
||||||
|
#include <config.h>
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
#define LOG_FLUSH (1<<0)
|
||||||
|
#define LOG_CPERROR (1<<1)
|
||||||
|
#define LOG_CPWARNING (1<<1)
|
||||||
|
|
||||||
|
/* TODO: set from external function */
|
||||||
|
static int flags = LOG_FLUSH|LOG_CPERROR;
|
||||||
|
static FILE * logfile;
|
||||||
|
|
||||||
|
void
|
||||||
|
log_puts(const char * str)
|
||||||
|
{
|
||||||
|
if (!logfile) logfile = stderr;
|
||||||
|
fputs(str, logfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
log_printf(const char * format, ...)
|
||||||
|
{
|
||||||
|
va_list marker;
|
||||||
|
if (!logfile) logfile = stderr;
|
||||||
|
va_start(marker, format);
|
||||||
|
vfprintf(logfile, format, marker);
|
||||||
|
va_end(marker);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
log_open(const char * filename)
|
||||||
|
{
|
||||||
|
if (logfile) log_close();
|
||||||
|
logfile = fopen(filename, "a");
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
log_close(void)
|
||||||
|
{
|
||||||
|
if (!logfile || logfile == stderr || logfile == stdout) return;
|
||||||
|
fclose(logfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_log_warn(const char * format, ...)
|
||||||
|
{
|
||||||
|
va_list marker;
|
||||||
|
if (!logfile) logfile = stderr;
|
||||||
|
va_start(marker, format);
|
||||||
|
fputs("WARNING: ", logfile);
|
||||||
|
vfprintf(logfile, format, marker);
|
||||||
|
va_end(marker);
|
||||||
|
if (logfile!=stderr) {
|
||||||
|
if (flags & LOG_CPWARNING) {
|
||||||
|
fputs("\bWARNING: ", stderr);
|
||||||
|
vfprintf(stderr, format, marker);
|
||||||
|
}
|
||||||
|
if (flags & LOG_FLUSH) {
|
||||||
|
fflush(logfile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_log_error(const char * format, ...)
|
||||||
|
{
|
||||||
|
va_list marker;
|
||||||
|
if (!logfile) logfile = stderr;
|
||||||
|
|
||||||
|
va_start(marker, format);
|
||||||
|
fputs("ERROR: ", logfile);
|
||||||
|
vfprintf(logfile, format, marker);
|
||||||
|
va_end(marker);
|
||||||
|
if (logfile!=stderr) {
|
||||||
|
if (flags & LOG_CPERROR) {
|
||||||
|
fputs("\bERROR: ", stderr);
|
||||||
|
vfprintf(stderr, format, marker);
|
||||||
|
}
|
||||||
|
if (flags & LOG_FLUSH) {
|
||||||
|
fflush(logfile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
extern void log_open(const char * filename);
|
||||||
|
extern void log_printf(const char * str, ...);
|
||||||
|
extern void log_puts(const char * str);
|
||||||
|
extern void log_close(void);
|
||||||
|
|
||||||
|
#define log_warning(x) _log_warn x
|
||||||
|
#define log_error(x) _log_error x
|
||||||
|
|
||||||
|
/* use macros above instead of these: */
|
||||||
|
extern void _log_warn(const char * format, ...);
|
||||||
|
extern void _log_error(const char * format, ...);
|
|
@ -1,6 +1,6 @@
|
||||||
/* vi: set ts=2:
|
/* vi: set ts=2:
|
||||||
*
|
*
|
||||||
* $Id: korrektur.c,v 1.20 2001/02/10 19:24:05 enno Exp $
|
* $Id: korrektur.c,v 1.21 2001/02/12 22:39:57 enno Exp $
|
||||||
* Eressea PB(E)M host Copyright (C) 1998-2000
|
* Eressea PB(E)M host Copyright (C) 1998-2000
|
||||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||||
|
@ -83,7 +83,7 @@ fix_skills(void)
|
||||||
/* make sure that this is done only once! */
|
/* make sure that this is done only once! */
|
||||||
while (a && a->data.i!=magic) a=a->next;
|
while (a && a->data.i!=magic) a=a->next;
|
||||||
if (a) {
|
if (a) {
|
||||||
fprintf(stderr, "WARNING: fix_skills() was called a second time\n");
|
log_warning(("[fix_skills] function was called a second time\n"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
a_add(&global.attribs, a_new(&at_key))->data.i = magic;
|
a_add(&global.attribs, a_new(&at_key))->data.i = magic;
|
||||||
|
@ -95,7 +95,7 @@ fix_skills(void)
|
||||||
if (fscanf(F, "%s %d %d %d %d %d\n", zText, &skill, &number, &from, &self, &teach)<=0) break;
|
if (fscanf(F, "%s %d %d %d %d %d\n", zText, &skill, &number, &from, &self, &teach)<=0) break;
|
||||||
u = findunit(atoi36(zText));
|
u = findunit(atoi36(zText));
|
||||||
if (u==NULL) {
|
if (u==NULL) {
|
||||||
fprintf(stderr, "unit %s not found!\n", zText);
|
log_warning(("[fix_skills] unit %s not found!\n", zText));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
myskill = get_skill(u, (skill_t)skill);
|
myskill = get_skill(u, (skill_t)skill);
|
||||||
|
@ -114,7 +114,7 @@ fix_skills(void)
|
||||||
attrib * a = a_find(global.attribs, &at_key); \
|
attrib * a = a_find(global.attribs, &at_key); \
|
||||||
while (a && a->data.i!=(magic)) a=a->next; \
|
while (a && a->data.i!=(magic)) a=a->next; \
|
||||||
if (a) { \
|
if (a) { \
|
||||||
fprintf(stderr, "WARNING: a unique fix was called a second time\n"); \
|
log_warning(("[do_once] a unique fix was called a second time\n")); \
|
||||||
return; \
|
return; \
|
||||||
} \
|
} \
|
||||||
else (fun); \
|
else (fun); \
|
||||||
|
@ -413,7 +413,7 @@ repair_illusion(void)
|
||||||
else if (i) continue;
|
else if (i) continue;
|
||||||
else {
|
else {
|
||||||
u->race = RC_ILLUSION;
|
u->race = RC_ILLUSION;
|
||||||
fprintf(stderr, "Illusion repariert: %s in Partei %s\n", unitname(u), factionid(u->faction));
|
log_puts("[repair_illusion] repariert: %s in Partei %s\n", unitname(u), factionid(u->faction));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!race[u->race].nonplayer && (
|
if(!race[u->race].nonplayer && (
|
||||||
|
@ -620,7 +620,7 @@ fix_migrants(void) {
|
||||||
for (u=r->units;u;u=u->next) {
|
for (u=r->units;u;u=u->next) {
|
||||||
if (u->race==RC_HUMAN) u->irace=RC_HUMAN;
|
if (u->race==RC_HUMAN) u->irace=RC_HUMAN;
|
||||||
if (u->irace!=u->race && u->race!=RC_ILLUSION && u->race!=RC_DAEMON) {
|
if (u->irace!=u->race && u->race!=RC_ILLUSION && u->race!=RC_DAEMON) {
|
||||||
fprintf(stderr, "WARNUNG: %s ist ein %s, als %s getarnt\n", unitname(u), race[u->race].name[0], race[u->irace].name[0]);
|
log_warning(("[fix_migrants] %s ist ein %s, als %s getarnt\n", unitname(u), race[u->race].name[0], race[u->irace].name[0]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* vi: set ts=2:
|
/* vi: set ts=2:
|
||||||
*
|
*
|
||||||
* $Id: main.c,v 1.14 2001/02/11 19:55:00 corwin Exp $
|
* $Id: main.c,v 1.15 2001/02/12 22:39:57 enno Exp $
|
||||||
* Eressea PB(E)M host Copyright (C) 1998-2000
|
* Eressea PB(E)M host Copyright (C) 1998-2000
|
||||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||||
|
@ -491,6 +491,9 @@ read_args(int argc, char **argv)
|
||||||
maxregions = atoi(argv[++i]);
|
maxregions = atoi(argv[++i]);
|
||||||
maxregions = (maxregions*81+80) / 81;
|
maxregions = (maxregions*81+80) / 81;
|
||||||
break;
|
break;
|
||||||
|
case 'l':
|
||||||
|
log_open(argv[++i]);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage(argv[0], argv[i]);
|
usage(argv[0], argv[i]);
|
||||||
}
|
}
|
||||||
|
@ -504,6 +507,7 @@ main(int argc, char *argv[])
|
||||||
int i;
|
int i;
|
||||||
char zText[MAX_PATH];
|
char zText[MAX_PATH];
|
||||||
|
|
||||||
|
log_open("eressea.log");
|
||||||
printf("\n%s PBEM host\n"
|
printf("\n%s PBEM host\n"
|
||||||
"Copyright (C) 1996-2001 C.Schlittchen, K.Zedel, E.Rehling, H.Peters.\n\n"
|
"Copyright (C) 1996-2001 C.Schlittchen, K.Zedel, E.Rehling, H.Peters.\n\n"
|
||||||
"Compilation: " __DATE__ " at " __TIME__ "\nVersion: %f\n\n", global.gamename, version());
|
"Compilation: " __DATE__ " at " __TIME__ "\nVersion: %f\n\n", global.gamename, version());
|
||||||
|
@ -538,6 +542,6 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
game_done();
|
game_done();
|
||||||
kernel_done();
|
kernel_done();
|
||||||
|
log_close();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue