Renamed log_err to log_fatal
This commit is contained in:
parent
45da155cb2
commit
3d5344de3b
17 changed files with 37 additions and 37 deletions
|
@ -144,7 +144,7 @@ if(FATALERRS)
|
|||
endif()
|
||||
|
||||
if(WIN32 OR APPLE)
|
||||
add_definitions(-DLOG_ERROR_MSGBOX)
|
||||
add_definitions(-DLOG_FATAL_MSGBOX)
|
||||
endif()
|
||||
|
||||
set(LIBs ${LIBs}
|
||||
|
|
|
@ -51,7 +51,7 @@ static char* format_log_string(LogLevel lvl, const char *funcname, const char *f
|
|||
}
|
||||
|
||||
noreturn static void log_abort(const char *msg) {
|
||||
#ifdef LOG_ERROR_MSGBOX
|
||||
#ifdef LOG_FATAL_MSGBOX
|
||||
if(msg) {
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Taisei error", msg, NULL);
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ static void log_internal(LogLevel lvl, const char *funcname, const char *fmt, va
|
|||
|
||||
free(str);
|
||||
|
||||
if(lvl & LOG_ERR) {
|
||||
if(lvl & LOG_FATAL) {
|
||||
log_abort(str);
|
||||
}
|
||||
}
|
||||
|
@ -106,8 +106,8 @@ noreturn void _taisei_log_fatal(LogLevel lvl, const char *funcname, const char *
|
|||
log_internal(lvl, funcname, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
// should usually not get here, log_internal will abort earlier if lvl is LOG_ERR
|
||||
// that is unless LOG_ERR is disabled for some reason
|
||||
// should usually not get here, log_internal will abort earlier if lvl is LOG_FATAL
|
||||
// that is unless LOG_FATAL is disabled for some reason
|
||||
log_abort(NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,10 +10,10 @@ typedef enum LogLevel {
|
|||
LOG_DEBUG = 1,
|
||||
LOG_INFO = 2,
|
||||
LOG_WARN = 4,
|
||||
LOG_ERR = 8,
|
||||
LOG_FATAL = 8,
|
||||
|
||||
LOG_SPAM = LOG_DEBUG | LOG_INFO,
|
||||
LOG_ALERT = LOG_WARN | LOG_ERR,
|
||||
LOG_ALERT = LOG_WARN | LOG_FATAL,
|
||||
LOG_ALL = LOG_SPAM | LOG_ALERT,
|
||||
} LogLevel;
|
||||
|
||||
|
@ -33,7 +33,7 @@ void log_add_output(LogLevel levels, SDL_RWops *output);
|
|||
|
||||
#define log_info(...) _taisei_log(LOG_INFO, __func__, __VA_ARGS__)
|
||||
#define log_warn(...) _taisei_log(LOG_WARN, __func__, __VA_ARGS__)
|
||||
#define log_err(...) _taisei_log_fatal(LOG_ERR, __func__, __VA_ARGS__)
|
||||
#define log_fatal(...) _taisei_log_fatal(LOG_FATAL, __func__, __VA_ARGS__)
|
||||
#define log_custom(lvl, ...) _taisei_log(lvl, __func__, __VA_ARGS__)
|
||||
|
||||
//
|
||||
|
|
|
@ -138,7 +138,7 @@ int main(int argc, char **argv) {
|
|||
MKDIR(get_replays_path());
|
||||
|
||||
if(chdir(get_prefix())) {
|
||||
log_err("chdir() failed: %s", strerror(errno));
|
||||
log_fatal("chdir() failed: %s", strerror(errno));
|
||||
} else {
|
||||
char cwd[1024]; // i don't care if this is not enough for you, getcwd is garbage
|
||||
getcwd(cwd, sizeof(cwd));
|
||||
|
@ -148,7 +148,7 @@ int main(int argc, char **argv) {
|
|||
config_load(CONFIG_FILE);
|
||||
|
||||
if(SDL_Init(SDL_INIT_VIDEO) < 0)
|
||||
log_err("SDL_Init() failed: %s", SDL_GetError());
|
||||
log_fatal("SDL_Init() failed: %s", SDL_GetError());
|
||||
|
||||
init_global();
|
||||
video_init();
|
||||
|
@ -187,7 +187,7 @@ int main(int argc, char **argv) {
|
|||
StageInfo* stg = stage_get(atoi(argv[1]));
|
||||
|
||||
if(!stg) {
|
||||
log_err("Invalid stage id");
|
||||
log_fatal("Invalid stage id");
|
||||
}
|
||||
|
||||
global.diff = stg->difficulty;
|
||||
|
|
|
@ -304,7 +304,7 @@ static void progress_write(SDL_RWops *file) {
|
|||
|
||||
if(SDL_RWtell(vfile) != bufsize) {
|
||||
free(buf);
|
||||
log_err("Buffer is inconsistent");
|
||||
log_fatal("Buffer is inconsistent");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -313,7 +313,7 @@ static void progress_write(SDL_RWops *file) {
|
|||
SDL_RWwrite(file, &cs, 4, 1);
|
||||
|
||||
if(!SDL_RWwrite(file, buf, bufsize, 1)) {
|
||||
log_err("SDL_RWwrite() failed: %s", SDL_GetError());
|
||||
log_fatal("SDL_RWwrite() failed: %s", SDL_GetError());
|
||||
free(buf);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ static void tsrand_error(const char *file, const char *func, unsigned int line,
|
|||
vsnprintf(buf, sizeof(buf), fmt, args);
|
||||
va_end(args);
|
||||
|
||||
log_err("%s(): %s [%s:%u]", func, buf, file, line);
|
||||
log_fatal("%s(): %s [%s:%u]", func, buf, file, line);
|
||||
}
|
||||
|
||||
#define TSRANDERR(...) tsrand_error(file, __func__, line, __VA_ARGS__)
|
||||
|
|
|
@ -365,7 +365,7 @@ int replay_read(Replay *rpy, SDL_RWops *file, ReplayReadMode mode) {
|
|||
mode &= REPLAY_READ_ALL;
|
||||
|
||||
if(!mode) {
|
||||
log_err("Called with invalid read mode");
|
||||
log_fatal("Called with invalid read mode");
|
||||
}
|
||||
|
||||
filesize = SDL_RWsize(file);
|
||||
|
@ -423,7 +423,7 @@ int replay_read(Replay *rpy, SDL_RWops *file, ReplayReadMode mode) {
|
|||
if(mode & REPLAY_READ_EVENTS) {
|
||||
if(!(mode & REPLAY_READ_META)) {
|
||||
if(!rpy->fileoffset) {
|
||||
log_err("Tried to read events before reading metadata");
|
||||
log_fatal("Tried to read events before reading metadata");
|
||||
}
|
||||
|
||||
for(int i = 0; i < rpy->numstages; ++i) {
|
||||
|
@ -626,7 +626,7 @@ int replay_test(void) {
|
|||
Replay rpy;
|
||||
|
||||
if(replay_read(&rpy, handle, REPLAY_READ_ALL)) {
|
||||
log_err("Succeeded loading garbage data as a replay... that shouldn't happen");
|
||||
log_fatal("Succeeded loading garbage data as a replay... that shouldn't happen");
|
||||
}
|
||||
|
||||
replay_destroy(&rpy);
|
||||
|
|
|
@ -17,7 +17,7 @@ TTF_Font *load_font(char *name, int size) {
|
|||
|
||||
TTF_Font *f = TTF_OpenFont(buf, size);
|
||||
if(!f)
|
||||
log_err("Failed to load font '%s'", buf);
|
||||
log_fatal("Failed to load font '%s'", buf);
|
||||
|
||||
log_info("Loaded '%s'", buf);
|
||||
|
||||
|
|
|
@ -175,7 +175,7 @@ static void parse_obj(const char *filename, ObjFileData *data) {
|
|||
}
|
||||
|
||||
if(jj == 0 || jj > 3 || segment[0] == '/')
|
||||
log_err("OBJ file '%s:%d': Parsing error: Corrupt face definition", filename,linen);
|
||||
log_fatal("OBJ file '%s:%d': Parsing error: Corrupt face definition", filename,linen);
|
||||
|
||||
data->indices = realloc(data->indices, sizeof(IVector)*(++data->icount));
|
||||
memcpy(data->indices[data->icount-1], ibuf, sizeof(IVector));
|
||||
|
@ -185,10 +185,10 @@ static void parse_obj(const char *filename, ObjFileData *data) {
|
|||
data->fverts = j;
|
||||
|
||||
if(data->fverts != j)
|
||||
log_err("OBJ file '%s:%d': Parsing error: face vertex count must stay the same in the whole file", filename, linen);
|
||||
log_fatal("OBJ file '%s:%d': Parsing error: face vertex count must stay the same in the whole file", filename, linen);
|
||||
|
||||
if(data->fverts != 3 && data->fverts != 4)
|
||||
log_err("OBJ file '%s:%d': Parsing error: face vertex count must be either 3 or 4", filename, linen);
|
||||
log_fatal("OBJ file '%s:%d': Parsing error: face vertex count must be either 3 or 4", filename, linen);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ static Resource* load_resource(ResourceHandler *handler, const char *path, const
|
|||
|
||||
if(!path) {
|
||||
if(!(flags & RESF_OPTIONAL)) {
|
||||
log_err("Required %s '%s' couldn't be located", typename, name);
|
||||
log_fatal("Required %s '%s' couldn't be located", typename, name);
|
||||
} else {
|
||||
log_warn("Failed to locate %s '%s'", typename, name);
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ static Resource* load_resource(ResourceHandler *handler, const char *path, const
|
|||
path = path ? path : "<path unknown>";
|
||||
|
||||
if(!(flags & RESF_OPTIONAL)) {
|
||||
log_err("Required %s '%s' couldn't be loaded (%s)", typename, name, path);
|
||||
log_fatal("Required %s '%s' couldn't be loaded (%s)", typename, name, path);
|
||||
} else {
|
||||
log_warn("Failed to load %s '%s' (%s)", typename, name, path);
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ Resource* get_resource(ResourceType type, const char *name, ResourceFlags flags)
|
|||
log_warn("%s '%s' was not preloaded", resource_type_names[type], name);
|
||||
|
||||
if(!(flags & RESF_OPTIONAL) && getenvint("TAISEI_PRELOAD_REQUIRED")) {
|
||||
log_err("Aborting due to TAISEI_PRELOAD_REQUIRED");
|
||||
log_fatal("Aborting due to TAISEI_PRELOAD_REQUIRED");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -102,9 +102,9 @@ void load_shader_snippets(const char *filename, const char *prefix, unsigned int
|
|||
ffoot = copy_segment(text, "%%FSHADER-FOOT%%", &ffsize);
|
||||
|
||||
if(!vhead || !fhead)
|
||||
log_err("Syntax Error: missing HEAD section(s)");
|
||||
log_fatal("Syntax Error: missing HEAD section(s)");
|
||||
if((vfoot == NULL) + (ffoot == NULL) != 1)
|
||||
log_err("Syntax Error: must contain exactly 1 FOOT section");
|
||||
log_fatal("Syntax Error: must contain exactly 1 FOOT section");
|
||||
|
||||
while((sec = strstr(sec, "%%"))) {
|
||||
sec += 2;
|
||||
|
@ -112,7 +112,7 @@ void load_shader_snippets(const char *filename, const char *prefix, unsigned int
|
|||
name = sec;
|
||||
nend = strstr(name, "%%");
|
||||
if(!nend)
|
||||
log_err("Syntax Error: expected '%%'");
|
||||
log_fatal("Syntax Error: expected '%%'");
|
||||
|
||||
sec = nend + 2;
|
||||
|
||||
|
|
|
@ -93,12 +93,12 @@ void stage_init_array(void) {
|
|||
#ifdef DEBUG
|
||||
for(int i = 0; stages[i].procs; ++i) {
|
||||
if(stages[i].type == STAGE_SPELL && !(stages[i].id & STAGE_SPELL_BIT)) {
|
||||
log_err("Spell stage has an ID without the spell bit set: 0x%04x", stages[i].id);
|
||||
log_fatal("Spell stage has an ID without the spell bit set: 0x%04x", stages[i].id);
|
||||
}
|
||||
|
||||
for(int j = 0; stages[j].procs; ++j) {
|
||||
if(i != j && stages[i].id == stages[j].id) {
|
||||
log_err("Duplicate ID 0x%04x in stages array, indices: %i, %i", stages[i].id, i, j);
|
||||
log_fatal("Duplicate ID 0x%04x in stages array, indices: %i, %i", stages[i].id, i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -701,7 +701,7 @@ void stage_loop(StageInfo *stage) {
|
|||
log_debug("Random seed: %u", seed);
|
||||
} else {
|
||||
if(!global.replay_stage) {
|
||||
log_err("Attemped to replay a NULL stage");
|
||||
log_fatal("Attemped to replay a NULL stage");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ void load_gl_library(void) {
|
|||
}
|
||||
|
||||
if(SDL_GL_LoadLibrary(lib) < 0) {
|
||||
log_err("SDL_GL_LoadLibrary() failed: %s", SDL_GetError());
|
||||
log_fatal("SDL_GL_LoadLibrary() failed: %s", SDL_GetError());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -240,7 +240,7 @@ char* read_all(const char *filename, int *outsize) {
|
|||
|
||||
SDL_RWops *file = SDL_RWFromFile(filename, "r");
|
||||
if(!file)
|
||||
log_err("SDL_RWFromFile() failed: %s", SDL_GetError());
|
||||
log_fatal("SDL_RWFromFile() failed: %s", SDL_GetError());
|
||||
|
||||
size = SDL_RWsize(file);
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@ char* strncpy() __attribute__((deprecated(
|
|||
|
||||
#undef errx
|
||||
noreturn void errx(int, const char*, ...) __attribute__((deprecated(
|
||||
"Use log_err instead")));
|
||||
"Use log_fatal instead")));
|
||||
|
||||
#undef warnx
|
||||
void warnx(const char*, ...) __attribute__((deprecated(
|
||||
|
|
|
@ -33,7 +33,7 @@ void init_vbo(VBO *vbo, int size) {
|
|||
|
||||
void vbo_add_verts(VBO *vbo, Vertex *verts, int count) {
|
||||
if(vbo->offset + count > vbo->size)
|
||||
log_err("Cannot add Vertices: VBO too small!");
|
||||
log_fatal("Cannot add Vertices: VBO too small!");
|
||||
|
||||
glBufferSubData(GL_ARRAY_BUFFER, sizeof(Vertex)*vbo->offset, sizeof(Vertex)*count, verts);
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ static void APIENTRY video_gl_debug(
|
|||
LogLevel lvl = LOG_DEBUG;
|
||||
|
||||
switch(type) {
|
||||
case GL_DEBUG_TYPE_ERROR: strtype = "error"; lvl = LOG_ERR; break;
|
||||
case GL_DEBUG_TYPE_ERROR: strtype = "error"; lvl = LOG_FATAL; break;
|
||||
case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: strtype = "deprecated"; lvl = LOG_WARN; break;
|
||||
case GL_DEBUG_TYPE_PORTABILITY: strtype = "portability"; break;
|
||||
case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: strtype = "undefined"; break;
|
||||
|
@ -179,7 +179,7 @@ static void _video_setmode(int w, int h, uint32_t flags, bool fallback) {
|
|||
}
|
||||
|
||||
if(!video.glcontext) {
|
||||
log_err("Error creating OpenGL context: %s", SDL_GetError());
|
||||
log_fatal("Error creating OpenGL context: %s", SDL_GetError());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,7 @@ static void _video_setmode(int w, int h, uint32_t flags, bool fallback) {
|
|||
}
|
||||
|
||||
if(fallback) {
|
||||
log_err("Error opening screen: %s", SDL_GetError());
|
||||
log_fatal("Error opening screen: %s", SDL_GetError());
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue