From d7b0ffa2976577cfff1a2b7a2df5ac421020ac4d Mon Sep 17 00:00:00 2001 From: Kubat <mael.martin31@gmail.com> Date: Thu, 14 May 2020 11:59:23 +0200 Subject: [PATCH] Simplify macro --- inc/common/macro.h | 72 ++++++++++++++++++------------------- src/cmd.c | 6 ++-- src/commands.c | 54 ++++++++++++++-------------- src/common.c | 8 ++--- src/config.c | 42 +++++++++++----------- src/database/config.c | 6 ++-- src/database/find.c | 6 ++-- src/database/open.c | 54 ++++++++++++++-------------- src/database/playlist.c | 8 ++--- src/database/queue.c | 36 +++++++++---------- src/database/stickers.c | 4 +-- src/database/update.c | 28 +++++++-------- src/database/user.c | 6 ++-- src/main/lkt.c | 6 ++-- src/main/server.c | 20 +++++------ src/mkv/utils.c | 2 +- src/mkv/write.c | 36 +++++++++---------- src/module/module_sdl2.c | 6 ++-- src/module/module_x11.c | 4 +-- src/module/mpv.c | 24 ++++++------- src/module/repo.c | 70 ++++++++++++++++++------------------ src/mthread/mthread.c | 20 +++++------ src/mthread/mthread_cond.c | 22 ++++++------ src/mthread/mthread_key.c | 12 +++---- src/mthread/mthread_mutex.c | 4 +-- src/net/listen.c | 40 ++++++++++----------- src/reg.c | 22 ++++++------ src/thread.c | 10 +++--- src/uri.c | 4 +-- 29 files changed, 316 insertions(+), 316 deletions(-) diff --git a/inc/common/macro.h b/inc/common/macro.h index 3bd755ba..5e0aebdf 100644 --- a/inc/common/macro.h +++ b/inc/common/macro.h @@ -22,27 +22,27 @@ #define MIN(a, b) ((a) > (b) ? (b) : (a)) #endif /* MIN */ -#define RETURN_IF(cond, msg, ret) \ - if (cond) { \ - LOG_ERROR_SCT("", "%s", msg); \ - return ret; \ +#define RETURN_IF(cond, msg, ret) \ + if (cond) { \ + LOG_ERROR("", "%s", msg); \ + return ret; \ } -#define GOTO_IF(cond, msg, label) \ - if (cond) { \ - LOG_ERROR_SCT("", "%s", msg); \ - goto label; \ +#define GOTO_IF(cond, msg, label) \ + if (cond) { \ + LOG_ERROR("", "%s", msg); \ + goto label; \ } #define GOTO_UNLESS(cond, msg, label) GOTO_IF(!(cond), msg, label) #define RETURN_UNLESS(cond, msg, ret) RETURN_IF(!(cond), msg, ret) #define NOTHING /* Usefull to return nothing. */ -#define STRTOL(ret, str, endptr, err_flag) \ -{ \ - err_flag = 0; \ - errno = 0; \ - ret = str == NULL ? 0 : strtol(str, &(endptr), 0); \ - err_flag = errno != 0 || endptr == str; \ +#define STRTOL(ret, str, endptr, err_flag) \ +{ \ + err_flag = 0; \ + errno = 0; \ + ret = str == NULL ? 0 : strtol(str, &(endptr), 0); \ + err_flag = errno != 0 || endptr == str; \ } #define ERROR 1 @@ -55,10 +55,10 @@ sizeof(section) > sizeof("") ? ("[" section "] ") : "", \ __func__, \ __VA_ARGS__) -#define LOG_INFO_SCT(section, format, ...) LOG(format, INFO, section, __VA_ARGS__) -#define LOG_WARN_SCT(section, format, ...) LOG(format, WARN, section, __VA_ARGS__) -#define LOG_ERROR_SCT(section, format, ...) LOG(format, ERROR, section, __VA_ARGS__) -#define LOG_DEBUG_SCT(section, format, ...) LOG(format, DEBUG, section, __VA_ARGS__) +#define LOG_INFO(section, format, ...) LOG(format, INFO, section, __VA_ARGS__) +#define LOG_WARN(section, format, ...) LOG(format, WARN, section, __VA_ARGS__) +#define LOG_ERROR(section, format, ...) LOG(format, ERROR, section, __VA_ARGS__) +#define LOG_DEBUG(section, format, ...) LOG(format, DEBUG, section, __VA_ARGS__) /* Defines for lektor */ @@ -125,43 +125,43 @@ typedef volatile enum { #define SQLITE_PREPARE(db, stmt, SQL, goto_label) \ if (sqlite3_prepare_v2((sqlite3 *) db, SQL, -1, &(stmt), 0) != SQLITE_OK) { \ - LOG_ERROR_SCT("DB", "Failed to prepare statement: %s", \ + LOG_ERROR("DB", "Failed to prepare statement: %s", \ sqlite3_errmsg((sqlite3 *) db)); \ goto goto_label; \ } #define SQLITE_EXEC(db, SQL, goto_label) \ if (sqlite3_exec((sqlite3 *) db, SQL, NULL, NULL, NULL) != SQLITE_OK) { \ - LOG_ERROR_SCT("DB", "Failed to exec statement: %s", \ + LOG_ERROR("DB", "Failed to exec statement: %s", \ sqlite3_errmsg((sqlite3 *) db)); \ goto goto_label; \ } -#define SQLITE_BIND_TEXT(db, stmt, pos, text, error) \ - if (sqlite3_bind_text(stmt, pos, text, -1, 0) != SQLITE_OK) { \ - LOG_ERROR_SCT("DB", "Failed to bind text %s at pos %d: %s", \ - text, pos, sqlite3_errmsg((sqlite3 *) db)); \ - goto error; \ +#define SQLITE_BIND_TEXT(db, stmt, pos, text, error) \ + if (sqlite3_bind_text(stmt, pos, text, -1, 0) != SQLITE_OK) { \ + LOG_ERROR("DB", "Failed to bind text %s at pos %d: %s", \ + text, pos, sqlite3_errmsg((sqlite3 *) db)); \ + goto error; \ } -#define SQLITE_BIND_INT(db, stmt, pos, integer, error) \ - if (sqlite3_bind_int(stmt, pos, integer) != SQLITE_OK) { \ - LOG_ERROR_SCT("DB", "Failed to bind int %d at pos %d: %s", \ - integer, pos, sqlite3_errmsg((sqlite3 *) db)); \ - goto error; \ +#define SQLITE_BIND_INT(db, stmt, pos, integer, error) \ + if (sqlite3_bind_int(stmt, pos, integer) != SQLITE_OK) { \ + LOG_ERROR("DB", "Failed to bind int %d at pos %d: %s", \ + integer, pos, sqlite3_errmsg((sqlite3 *) db));\ + goto error; \ } -#define SQLITE_STEP(db, stmt, code, error) \ - if (sqlite3_step(stmt) != code) { \ - LOG_ERROR_SCT("DB", "Failed to step: %s", \ - sqlite3_errmsg((sqlite3 *) db)); \ - goto error; \ +#define SQLITE_STEP(db, stmt, code, error) \ + if (sqlite3_step(stmt) != code) { \ + LOG_ERROR("DB", "Failed to step: %s", \ + sqlite3_errmsg((sqlite3 *) db)); \ + goto error; \ } #define SQLITE_STEP_ROW(db, stmt, error) SQLITE_STEP(db, stmt, SQLITE_ROW, error) #define SQLITE_STEP_DONE(db, stmt, error) SQLITE_STEP(db, stmt, SQLITE_DONE, error) -#define SQLITE_DO_ROLLBACK(db) \ +#define SQLITE_DO_ROLLBACK(db) \ sqlite3_exec((sqlite3 *) db, "ROLLBACK TRANSACTION;\n", NULL, NULL, NULL); #define STR_MATCH(str1, str2) (! strcasecmp(str1, str2)) diff --git a/src/cmd.c b/src/cmd.c index d1a1893d..4f19b195 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -67,14 +67,14 @@ not_found: it->call(&arguments); } - LOG_ERROR_SCT("COMMAND", "Command '%s' could not be found", argv[0]); + LOG_ERROR("COMMAND", "Command '%s' could not be found", argv[0]); exit(EXIT_FAILURE); help: help__(); not_exclusive: - LOG_ERROR_SCT("COMMAND", "Failed to determine option, '%s' not exclusive", - argv[0]); + LOG_ERROR("COMMAND", "Failed to determine option, '%s' not exclusive", + argv[0]); exit(EXIT_FAILURE); } diff --git a/src/commands.c b/src/commands.c index d2db41c8..a4b34dba 100644 --- a/src/commands.c +++ b/src/commands.c @@ -26,7 +26,7 @@ command_restart(struct lkt_state *srv, size_t c) struct lkt_queue_state sta = {0}; RETURN_UNLESS(lkt_client_auth(srv, c, false), "Failed to authentificate user", false); if (!executable_name) { - LOG_ERROR_SCT("GENERAL", "%s", "Can't restart if the executable path was not found at start-up"); + LOG_ERROR("GENERAL", "%s", "Can't restart if the executable path was not found at start-up"); return false; } close(srv->fds[0].fd); @@ -41,13 +41,13 @@ command_restart(struct lkt_state *srv, size_t c) env_set(LKT_ENV_CURRENT, pos); free(pos); } else - LOG_WARN_SCT("GENERAL", "Failed to malloc, don't set %s to %d", - LKT_ENV_CURRENT, sta.current); + LOG_WARN("GENERAL", "Failed to malloc, don't set %s to %d", + LKT_ENV_CURRENT, sta.current); } else env_set(LKT_ENV_CURRENT, "NULL"); database_close_all(); execv(executable_name, (char *const *) argv); - LOG_ERROR_SCT("GENERAL", "%s", "Failed to exec lektor or OS not supported"); + LOG_ERROR("GENERAL", "%s", "Failed to exec lektor or OS not supported"); return false; } @@ -88,7 +88,7 @@ inline bool command_kill(struct lkt_state *srv, size_t c) { RETURN_UNLESS(lkt_client_auth(srv, c, false), "Failed to authentificate user", false); - LOG_INFO_SCT("GENERAL", "%s", "Stopping lektord"); + LOG_INFO("GENERAL", "%s", "Stopping lektord"); close(srv->fds[0].fd); lkt_queue_free(&srv->queue); database_close_all(); @@ -105,7 +105,7 @@ command_currentsong(struct lkt_state *srv, size_t c) memset(&kara, 0, sizeof(struct kara_metadata)); if (!database_queue_current_kara(srv->db, &kara, NULL)) - LOG_ERROR_SCT("COMMAND", "%s", "Failed to get information about the current kara"); + LOG_ERROR("COMMAND", "%s", "Failed to get information about the current kara"); out = lkt_message_new(); idx = safe_snprintf(out->data, LKT_MESSAGE_MAX, @@ -259,7 +259,7 @@ command_add(volatile sqlite3 *db, struct lkt_win *win, char *args[LKT_MESSAGE_AR ret = database_queue_add_uri(db, &uri, priority); lkt_uri_free(&uri); if (!ret) - LOG_ERROR_SCT("COMMAND", "Failed to add with priority %d in queue", priority); + LOG_ERROR("COMMAND", "Failed to add with priority %d in queue", priority); return ret; } @@ -307,13 +307,13 @@ command_delid(volatile sqlite3 *db, struct lkt_win *win, char *id_str, mpd_idle_ if (id == (long) uri) { if (database_queue_skip_current(db, filepath)) { if (!win->load_file(win, filepath)) { - LOG_ERROR_SCT("COMMAND", "Failed to skip current kara to delete id %ld", id); + LOG_ERROR("COMMAND", "Failed to skip current kara to delete id %ld", id); return false; } } else { - LOG_WARN_SCT("COMMAND", "Failed to skip current kara to delete id %ld, stop playback", id); + LOG_WARN("COMMAND", "Failed to skip current kara to delete id %ld, stop playback", id); win->close(win); } } @@ -390,7 +390,7 @@ command_idle(struct lkt_state *srv, size_t c, struct lkt_command *cmd) if (!once) lkt_client_add_mask(srv, c, MPD_IDLE_ALL); - LOG_INFO_SCT("COMMAND", "Idle mask for client number %ld is 0x%X", c, lkt_client_get_mask(srv, c)); + LOG_INFO("COMMAND", "Idle mask for client number %ld is 0x%X", c, lkt_client_get_mask(srv, c)); return true; } @@ -484,7 +484,7 @@ command_find(struct lkt_state *srv, size_t c, char *cmd_args[LKT_MESSAGE_ARGS_MA if (count) lkt_set_continuation(srv, c, continuation + count); else - LOG_WARN_SCT("COMMAND", "%s", "Nothing found"); + LOG_WARN("COMMAND", "%s", "Nothing found"); return true; } @@ -527,7 +527,7 @@ command_set_playback_option(struct lkt_state *srv, size_t c, enum lkt_playback_o break; case lkt_playback_option_volume: ret = database_config_queue(srv->db, "volume", val); - LOG_INFO_SCT("COMMAND", "Set volume to %ld", val); + LOG_INFO("COMMAND", "Set volume to %ld", val); ret &= win->set_volume(win, val); srv->mpd_idle_events |= MPD_IDLE_MIXER; break; @@ -565,12 +565,12 @@ command_plt_add(volatile sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], mpd_idle else { if (!lkt_uri_from(&uri, args[1])) { - LOG_ERROR_SCT("COMMAND", "%s", "Failed to get uri"); + LOG_ERROR("COMMAND", "%s", "Failed to get uri"); goto end_plt_add_uri; } else if (!database_plt_add_uri(db, args[0], &uri)) { - LOG_ERROR_SCT("COMMAND", "Failed to add uri '%s' to playlist", args[1]); + LOG_ERROR("COMMAND", "Failed to add uri '%s' to playlist", args[1]); goto end_plt_add_uri; } @@ -628,7 +628,7 @@ command_plt_export(volatile sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], mpd_i RETURN_UNLESS(database_attach(db, args[0], args[1]), "Failed to attach database", false); RETURN_UNLESS(database_plt_export(db, args[0]), "Failed to export playlist", false); RETURN_UNLESS(database_detach(db, args[0]), "Failed to detach database", false); - LOG_INFO_SCT("COMMAND", "Exported playlist %s with path '%s'", args[0], args[1]); + LOG_INFO("COMMAND", "Exported playlist %s with path '%s'", args[0], args[1]); *watch_mask_ptr |= MPD_IDLE_PLAYLIST; return true; } @@ -640,7 +640,7 @@ command_plt_import(volatile sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], mpd_i RETURN_UNLESS(database_attach(db, args[0], args[1]), "Failed to attach database", false); RETURN_UNLESS(database_plt_import(db, args[0]), "Failed to import playlist", false); RETURN_UNLESS(database_detach(db, args[0]), "Failed to detach playlist", false); - LOG_INFO_SCT("COMMAND", "Imported playlist %s with path '%s'", args[0], args[1]); + LOG_INFO("COMMAND", "Imported playlist %s with path '%s'", args[0], args[1]); *watch_mask_ptr |= MPD_IDLE_PLAYLIST; return true; } @@ -701,7 +701,7 @@ command_queue_list(struct lkt_state *srv, size_t c, char *args[LKT_MESSAGE_ARGS_ tmp_switch = to; to = from; from = tmp_switch; - LOG_INFO_SCT("COMMAND", "Switch range values wrong order, now %d:%d", from, to); + LOG_INFO("COMMAND", "Switch range values wrong order, now %d:%d", from, to); } goto is_a_range; @@ -717,11 +717,11 @@ only_one: /* The command is used with a range specifier. */ is_a_range: if (to - from + 1 < lkt_remaining_msg(srv, c) - 2) { - LOG_INFO_SCT("COMMAND", "Got range %d:%d, no continuation needed", from, to); + LOG_INFO("COMMAND", "Got range %d:%d, no continuation needed", from, to); lkt_set_continuation(srv, c, 0); return database_queue_list(srv->db, from, to, &callback); } else { - LOG_INFO_SCT("COMMAND", "Got range %d:%d, continuation needed", from, to); + LOG_INFO("COMMAND", "Got range %d:%d, continuation needed", from, to); to = from + lkt_remaining_msg(srv, c) - 3; lkt_set_continuation(srv, c, to + 1); return database_queue_list(srv->db, from, to, &callback); @@ -761,13 +761,13 @@ sticker_send(struct lkt_state *srv, size_t c, char *name, char *type, int id, in bool command_sticker_create(struct lkt_state *srv, size_t c, char *argv[LKT_MESSAGE_ARGS_MAX]) { - LOG_INFO_SCT("COMMAND", "Client %ld is using the sticker create command", c); + LOG_INFO("COMMAND", "Client %ld is using the sticker create command", c); RETURN_UNLESS(argv[0], "Invalid argument", false); if (!database_sticker_create(srv->db, argv[0])) { - LOG_ERROR_SCT("COMMAND", "Failed to create sticker '%s'", argv[0]); + LOG_ERROR("COMMAND", "Failed to create sticker '%s'", argv[0]); return false; } - LOG_INFO_SCT("COMMAND", "Created sticker '%s'", argv[0]); + LOG_INFO("COMMAND", "Created sticker '%s'", argv[0]); return true; } @@ -780,7 +780,7 @@ command_sticker_set(struct lkt_state *srv, size_t c, char *argv[LKT_MESSAGE_ARGS STRTOL(uri, argv[1], endptr, err1); STRTOL(value, argv[3], endptr, err2); RETURN_IF(err1 || err2, "STRTOL failed", false); - LOG_INFO_SCT("COMMAND", "Client %ld is using the sticker set command", c); + LOG_INFO("COMMAND", "Client %ld is using the sticker set command", c); RETURN_UNLESS(database_sticker_set(srv->db, argv[0], argv[2], uri, value), "Failed to get sticker", false); srv->mpd_idle_events |= MPD_IDLE_STICKER; return true; @@ -789,7 +789,7 @@ command_sticker_set(struct lkt_state *srv, size_t c, char *argv[LKT_MESSAGE_ARGS bool command_sticker_get(struct lkt_state *srv, size_t c, char *argv[LKT_MESSAGE_ARGS_MAX]) { - LOG_INFO_SCT("COMMAND", "Client %ld is using the sticker get command", c); + LOG_INFO("COMMAND", "Client %ld is using the sticker get command", c); struct lkt_search callback = { .srv = srv, .c = c, @@ -840,14 +840,14 @@ command_sticker_get(struct lkt_state *srv, size_t c, char *argv[LKT_MESSAGE_ARGS return true; unknown: - LOG_ERROR_SCT("COMMAND", "%s", "Specified command is invalid or unknown"); + LOG_ERROR("COMMAND", "%s", "Specified command is invalid or unknown"); return false; } bool command_sticker_delete(struct lkt_state *srv, size_t c, char *argv[LKT_MESSAGE_ARGS_MAX]) { - LOG_INFO_SCT("COMMAND", "Client %ld is using the sticker delete command", c); + LOG_INFO("COMMAND", "Client %ld is using the sticker delete command", c); RETURN_UNLESS(argv[0] && argv[1] && argv[2], "Invalid argument", false); int uri = atoi(argv[1]); srv->mpd_idle_events |= MPD_IDLE_STICKER; @@ -857,7 +857,7 @@ command_sticker_delete(struct lkt_state *srv, size_t c, char *argv[LKT_MESSAGE_A bool command_sticker_destroy(struct lkt_state *srv, size_t c, char *argv[LKT_MESSAGE_ARGS_MAX]) { - LOG_INFO_SCT("COMMAND", "Client %ld is using the sticker destroy command", c); + LOG_INFO("COMMAND", "Client %ld is using the sticker destroy command", c); RETURN_UNLESS(argv[0], "Invalid argument", false); return database_sticker_delete(srv->db, argv[0]); } diff --git a/src/common.c b/src/common.c index 77cade84..0894ea89 100644 --- a/src/common.c +++ b/src/common.c @@ -11,8 +11,8 @@ void __not_implemented(const char *func, char *file, int line) { - LOG_ERROR_SCT("GENERAL", "Function %s in file %s at line %d not " - "implemented", func, file, line); + LOG_ERROR("GENERAL", "Function %s in file %s at line %d not " + "implemented", func, file, line); abort(); } @@ -146,8 +146,8 @@ safe_malloc(size_t size) void *tmp; tmp = malloc(size); if (!tmp) { - LOG_ERROR_SCT("GENERAL", "Out of memory, can't alloc " - "'%ld' Bytes", size); + LOG_ERROR("GENERAL", "Out of memory, can't alloc " + "'%ld' Bytes", size); exit(1); } return tmp; diff --git a/src/config.c b/src/config.c index b1bb5d58..f2ccb89a 100644 --- a/src/config.c +++ b/src/config.c @@ -54,7 +54,7 @@ ini_parse(const char *path, volatile sqlite3 *db) int error = 0, linenum = 0, len; FILE *file = fopen(path, "r"); if (!file) { - LOG_ERROR_SCT("PARSER", "Failed to open config file '%s'", path); + LOG_ERROR("PARSER", "Failed to open config file '%s'", path); return 1; } @@ -80,8 +80,8 @@ ini_parse(const char *path, volatile sqlite3 *db) else { error = 1; - LOG_ERROR_SCT("PARSER", "Invalid section name at line '%d'", - linenum); + LOG_ERROR("PARSER", "Invalid section name at line '%d'", + linenum); } } @@ -105,16 +105,16 @@ ini_parse(const char *path, volatile sqlite3 *db) /* Handle the SECTION, NAME[:=]VALUE */ if (handler(db, section, name, value)) { error = 1; - LOG_ERROR_SCT("PARSER", "Failed to '[handle] %s, " - "%s{:,=}%s' at line '%d'", - section, name, value, linenum); + LOG_ERROR("PARSER", "Failed to '[handle] %s, " + "%s{:,=}%s' at line '%d'", + section, name, value, linenum); } } else { error = 1; - LOG_ERROR_SCT("PARSER", "Invalid name[:=]value pair at " - "line '%d'", linenum); + LOG_ERROR("PARSER", "Invalid name[:=]value pair at " + "line '%d'", linenum); } } } @@ -122,8 +122,8 @@ ini_parse(const char *path, volatile sqlite3 *db) /* End of the function */ fclose(file); if (error) - LOG_ERROR_SCT("PARSER", "An error occured while parsing the " - "file '%s'", path); + LOG_ERROR("PARSER", "An error occured while parsing the " + "file '%s'", path); return error; } @@ -142,7 +142,7 @@ config_detect_file(char *conf, size_t conf_len) /* Try the current working dir config file. */ if (getcwd(conf, conf_len - 1) != NULL) { strncat(conf, "/lektor.ini", conf_len - 1); - LOG_INFO_SCT("CONFIG", "Trying %s", conf); + LOG_INFO("CONFIG", "Trying %s", conf); if (!access(conf, R_OK | F_OK)) goto found; } @@ -164,7 +164,7 @@ config_detect_file(char *conf, size_t conf_len) memcpy(conf, home, (strlen(home) + 1) * sizeof(char)); strncat(conf, "/.config/lektor/lektor.ini", conf_len - 1); skip_this_strcat: - LOG_INFO_SCT("CONFIG", "Trying %s", conf); + LOG_INFO("CONFIG", "Trying %s", conf); if (!access(conf, R_OK | F_OK)) goto found; @@ -172,31 +172,31 @@ no_config_directory: /* Try the '/opt/lektor' file. */ memcpy(conf, "/opt/lektor/lektor.ini", sizeof("/opt/lektor/lektor.ini")); - LOG_INFO_SCT("CONFIG", "Trying %s", conf); + LOG_INFO("CONFIG", "Trying %s", conf); if (!access(conf, R_OK | F_OK)) goto found; /* Try the '/usr/local/etc/lektor.ini' file. */ memcpy(conf, "/usr/local/etc/lektor.ini", sizeof("/usr/local/etc/lektor.ini")); - LOG_INFO_SCT("CONFIG", "Trying %s", conf); + LOG_INFO("CONFIG", "Trying %s", conf); if (!access(conf, R_OK | F_OK)) goto found; /* Try the '/etc/lektor.ini' file. */ memcpy(conf, "/etc/lektor.ini", sizeof("/etc/lektor.ini")); - LOG_INFO_SCT("CONFIG", "Trying %s", conf); + LOG_INFO("CONFIG", "Trying %s", conf); if (!access(conf, R_OK | F_OK)) goto found; /* Error */ - LOG_ERROR_SCT("CONFIG", "An error occured with file %s: %s", - conf, strerror(errno)); + LOG_ERROR("CONFIG", "An error occured with file %s: %s", + conf, strerror(errno)); if (is_malloc) free(conf); return 1; found: - LOG_INFO_SCT("CONFIG", "Using file %s", conf); + LOG_INFO("CONFIG", "Using file %s", conf); return 0; } @@ -204,18 +204,18 @@ int config_new(volatile sqlite3 *db, const char *conf) { if (ini_parse(conf, db)) { - LOG_ERROR_SCT("CONFIG", "Failed to parse file %s", conf); + LOG_ERROR("CONFIG", "Failed to parse file %s", conf); goto error; } if (!database_validate_conf(db)) { - LOG_ERROR_SCT("CONFIG", "Configuration file %s is incomplete", conf); + LOG_ERROR("CONFIG", "Configuration file %s is incomplete", conf); goto error; } return 0; error: - LOG_ERROR_SCT("CONFIG", "%s", "Errors detected, here is a default config"); + LOG_ERROR("CONFIG", "%s", "Errors detected, here is a default config"); config_default(stdout); return 1; } diff --git a/src/database/config.c b/src/database/config.c index 098377b2..ae0a1f9b 100644 --- a/src/database/config.c +++ b/src/database/config.c @@ -27,8 +27,8 @@ database_config_set(volatile sqlite3 *db, const char *section, const char *key, code = sqlite3_step(stmt); if (code != SQLITE_OK && code != SQLITE_DONE) { - LOG_ERROR_SCT("DB", "Failed to insert or replace: %s", - sqlite3_errmsg((sqlite3 *) db)); + LOG_ERROR("DB", "Failed to insert or replace: %s", + sqlite3_errmsg((sqlite3 *) db)); goto error; } @@ -167,7 +167,7 @@ database_validate_conf(volatile sqlite3 *db) #define value_opt(name, value) #define value(name, value) \ if (!database_config_exists(db, section, name)) { \ - LOG_ERROR_SCT("CONFIG", "Missing option \""name"\" in section \"%s\"",\ + LOG_ERROR("CONFIG", "Missing option \""name"\" in section \"%s\"",\ section); \ return false; \ } diff --git a/src/database/find.c b/src/database/find.c index 41a1eac5..ef8f475a 100644 --- a/src/database/find.c +++ b/src/database/find.c @@ -117,8 +117,8 @@ database_search_iter(struct lkt_search *item) goto end; if (code != SQLITE_ROW) { - LOG_ERROR_SCT("DB", "Step failed, expected a ROW or a DONE: %s", - sqlite3_errmsg((sqlite3 *) item->db)); + LOG_ERROR("DB", "Step failed, expected a ROW or a DONE: %s", + sqlite3_errmsg((sqlite3 *) item->db)); goto end; } @@ -139,7 +139,7 @@ database_search_iter(struct lkt_search *item) (item->srv, item->c, sql_row, type, id, code); case lkt_search_playlist: default: - LOG_WARN_SCT("DB", "Search type %d is not implemented", item->type); + LOG_WARN("DB", "Search type %d is not implemented", item->type); goto end; } diff --git a/src/database/open.c b/src/database/open.c index d0270786..f82bbc7b 100644 --- a/src/database/open.c +++ b/src/database/open.c @@ -31,16 +31,16 @@ __dec(volatile sqlite3 *db, const char *name) safe_snprintf(SQL, LKT_MAX_SQLITE_STATEMENT, "UPDATE %s.misc SET opened = 0;", name); SQLITE_EXEC(db, SQL, error); - LOG_INFO_SCT("DB", "Dec open count on db '%s'", name); + LOG_INFO("DB", "Dec open count on db '%s'", name); return; error: - LOG_ERROR_SCT("DB", "%s", "Faield to close database"); + LOG_ERROR("DB", "%s", "Faield to close database"); } void database_close_all(void) { - LOG_INFO_SCT("GARBAGE", "%s", "Closing all db"); + LOG_INFO("GARBAGE", "%s", "Closing all db"); if (pthread_mutex_trylock(&mtx)) return; struct named_db *item; @@ -50,7 +50,7 @@ database_close_all(void) free((void *) item->name); free(item); } - LOG_INFO_SCT("GARBAGE", "%s", "All db closed"); + LOG_INFO("GARBAGE", "%s", "All db closed"); stack_free(&db_stack); } @@ -75,7 +75,7 @@ __inc(volatile sqlite3 *db, const char *name, bool check) exit(EXIT_FAILURE); return; error: - LOG_ERROR_SCT("DB", "%s", "Database already in use"); + LOG_ERROR("DB", "%s", "Database already in use"); if (check) exit(EXIT_FAILURE); __dec(db, name); @@ -117,7 +117,7 @@ __attach(volatile sqlite3 *db, const char *name, const char *path) safe_snprintf(SQL_ATTACH, LKT_MAX_SQLITE_STATEMENT, SQL_ATTACH_TEMPLATE, path, name); SQLITE_EXEC(db, SQL_ATTACH, err_no_attach); - LOG_INFO_SCT("DB", "Attached database '%s' with path '%s'", name, path); + LOG_INFO("DB", "Attached database '%s' with path '%s'", name, path); ret = true; err_no_attach: return ret; @@ -133,7 +133,7 @@ __detach(volatile sqlite3 *db, const char *name) safe_snprintf(SQL_DETACH, LKT_MAX_SQLITE_STATEMENT, SQL_DETACH_TEMPLATE, name); SQLITE_EXEC(db, SQL_DETACH, err_no_detach); - LOG_INFO_SCT("DB", "Detached database '%s'", name); + LOG_INFO("DB", "Detached database '%s'", name); ret = true; err_no_detach: return ret; @@ -155,7 +155,7 @@ __check_schema(volatile sqlite3 *db) if (9 != sqlite3_column_int(stmt, 0)) return true; error: - LOG_ERROR_SCT("DB", "%s", "Schema is invalid: missing tables"); + LOG_ERROR("DB", "%s", "Schema is invalid: missing tables"); return false; } @@ -181,7 +181,7 @@ database_open(volatile sqlite3 *db, const char *dbpath, bool check) { bool retry = false; if (is_sql_str_invalid(dbpath)) { - LOG_ERROR_SCT("DB", "The database path '%s' is invalid", dbpath); + LOG_ERROR("DB", "The database path '%s' is invalid", dbpath); return false; } @@ -197,18 +197,18 @@ retry: /* Need init */ init: if (retry) { - LOG_ERROR_SCT("DB", "Retry to init database '%s', this is an error", - dbpath); + LOG_ERROR("DB", "Retry to init database '%s', this is an error", + dbpath); return false; } retry = true; - LOG_WARN_SCT("DB", "Database '%s' is not correctly initialized, init it", - dbpath); + LOG_WARN("DB", "Database '%s' is not correctly initialized, init it", + dbpath); __detach(db, PROTECTED_DATABASE) ; if (database_init(dbpath)) goto retry; else { - LOG_ERROR_SCT("DB", "Failed to init database '%s'", dbpath); + LOG_ERROR("DB", "Failed to init database '%s'", dbpath); return false; } } @@ -221,22 +221,22 @@ database_attach(volatile sqlite3 *db, const char *name, const char *dbpath) "database with the same name", false); if (is_sql_str_invalid(name)) { - LOG_ERROR_SCT("DB", "The database name '%s' is invalid", name); + LOG_ERROR("DB", "The database name '%s' is invalid", name); return false; } if (__is_attached(db, name)) { - LOG_ERROR_SCT("DB", "The database '%s' is already attached", name); + LOG_ERROR("DB", "The database '%s' is already attached", name); return false; } if (!__attach(db, name, dbpath)) { - LOG_ERROR_SCT("DB", "Failed to attach database named '%s' with " - "path '%s'", name, dbpath); + LOG_ERROR("DB", "Failed to attach database named '%s' with " + "path '%s'", name, dbpath); return false; } - LOG_INFO_SCT("DB", "Database '%s' attached", name); + LOG_INFO("DB", "Database '%s' attached", name); return true; } @@ -247,21 +247,21 @@ database_detach(volatile sqlite3 *db, const char *name) PROTECTED_DATABASE " is protected, can't detach it", false); if (is_sql_str_invalid(name)) { - LOG_ERROR_SCT("DB", "The database name '%s' is invalid", name); + LOG_ERROR("DB", "The database name '%s' is invalid", name); return false; } if (!__is_attached(db, name)) { - LOG_ERROR_SCT("DB", "The database '%s' is not attached", name); + LOG_ERROR("DB", "The database '%s' is not attached", name); return false; } if (!__detach(db, name)) { - LOG_ERROR_SCT("DB", "Failed to detach database named %s", name); + LOG_ERROR("DB", "Failed to detach database named %s", name); return false; } - LOG_INFO_SCT("DB", "Database '%s' detached", name); + LOG_INFO("DB", "Database '%s' detached", name); return true; } @@ -272,11 +272,11 @@ database_init(const char *dbpath) if (SQLITE_OK != sqlite3_open(dbpath, &db)) goto error; SQLITE_EXEC(db, (const char *) ___src_database_disk_sql, error); - LOG_INFO_SCT("DB", "Initialized the 'disk' database successfully, " - "path was '%s'", dbpath); + LOG_INFO("DB", "Initialized the 'disk' database successfully, " + "path was '%s'", dbpath); return true; error: - LOG_ERROR_SCT("DB", "Failed to init the 'disk' database, path was '%s'", - dbpath); + LOG_ERROR("DB", "Failed to init the 'disk' database, path was '%s'", + dbpath); return false; } diff --git a/src/database/playlist.c b/src/database/playlist.c index 7bcda41a..61b0abf7 100644 --- a/src/database/playlist.c +++ b/src/database/playlist.c @@ -106,7 +106,7 @@ database_plt_export(volatile sqlite3 *db, const char *name) sqlite3_stmt *stmt = NULL; if (is_sql_str_invalid(name)) { - LOG_ERROR_SCT("DB", "The playlist name '%s' is invalid", name); + LOG_ERROR("DB", "The playlist name '%s' is invalid", name); goto error; } @@ -119,8 +119,8 @@ database_plt_export(volatile sqlite3 *db, const char *name) code = sqlite3_step(stmt); if (code != SQLITE_DONE && code != SQLITE_OK) { - LOG_ERROR_SCT("DB", "Failed to create schema: %s", - sqlite3_errmsg((sqlite3 *) db)); + LOG_ERROR("DB", "Failed to create schema: %s", + sqlite3_errmsg((sqlite3 *) db)); goto error; } @@ -142,7 +142,7 @@ database_plt_import(volatile sqlite3 *db, const char *name) char SQL_STMT[LKT_MAX_SQLITE_STATEMENT], ret = false; if (is_sql_str_invalid(name)) { - LOG_ERROR_SCT("DB", "The playlist name '%s' is invalid", name); + LOG_ERROR("DB", "The playlist name '%s' is invalid", name); goto error; } diff --git a/src/database/queue.c b/src/database/queue.c index ed6ddc6f..80a3d9e2 100644 --- a/src/database/queue.c +++ b/src/database/queue.c @@ -118,7 +118,7 @@ error: #define reorder(db, prio, error) \ if (prio > 1) { \ if (__queue_reorder(db)) \ - LOG_INFO_SCT("DB", "%s", "Queue has been reordered"); \ + LOG_INFO("DB", "%s", "Queue has been reordered"); \ else \ goto error; \ } @@ -282,8 +282,8 @@ database_queue_add_uri(volatile sqlite3 *db, struct lkt_uri *uri, int priority) case uri_playlist: return database_queue_add_plt(db, (char *) uri->value, priority); default: - LOG_WARN_SCT("DB", "Add to queue for uri of type %d is not" - " implemented", uri->type); + LOG_WARN("DB", "Add to queue for uri of type %d is not" + " implemented", uri->type); return false; } } @@ -343,19 +343,19 @@ database_queue_next(volatile sqlite3 *db, char filepath[PATH_MAX]) if (filepath != NULL) strncpy(filepath, sqlite3_column_chars(stmt, 0), PATH_MAX); else { - LOG_ERROR_SCT("DB", "Failed to get file, id was %d", id); + LOG_ERROR("DB", "Failed to get file, id was %d", id); goto error; } } else if (code == SQLITE_DONE) { - LOG_ERROR_SCT("DB", "%s", "Failed to get next"); + LOG_ERROR("DB", "%s", "Failed to get next"); goto error; } else { - LOG_ERROR_SCT("DB", "Failed to fetch next kara: %s", - sqlite3_errmsg((sqlite3 *) db)); + LOG_ERROR("DB", "Failed to fetch next kara: %s", + sqlite3_errmsg((sqlite3 *) db)); goto error; } @@ -407,19 +407,19 @@ database_queue_prev(volatile sqlite3 *db, char filepath[PATH_MAX]) if (filepath != NULL) strncpy(filepath, sqlite3_column_chars(stmt, 0), PATH_MAX); else { - LOG_ERROR_SCT("DB", "Failed to get file, position was %d", id); + LOG_ERROR("DB", "Failed to get file, position was %d", id); goto error; } } else if (code == SQLITE_DONE) { - LOG_ERROR_SCT("DB", "%s", "Failed to get previous"); + LOG_ERROR("DB", "%s", "Failed to get previous"); goto error; } else { - LOG_ERROR_SCT("DB", "Failed to fetch prev kara: %s", - sqlite3_errmsg((sqlite3 *) db)); + LOG_ERROR("DB", "Failed to fetch prev kara: %s", + sqlite3_errmsg((sqlite3 *) db)); goto error; } @@ -455,7 +455,7 @@ database_queue_move(volatile sqlite3 *db, int from, int to) code = sqlite3_step(stmt); if (code != SQLITE_ROW && code != SQLITE_DONE && code != SQLITE_OK) { - LOG_ERROR_SCT("DB", "%s", "Move failed"); + LOG_ERROR("DB", "%s", "Move failed"); goto error; } @@ -481,8 +481,8 @@ database_queue_play(volatile sqlite3 *db, int pos) code = sqlite3_step(stmt); if (code != SQLITE_OK && code != SQLITE_DONE) { - LOG_ERROR_SCT("DB", "Failed to update queue_state: %s", - sqlite3_errmsg((sqlite3 *) db)); + LOG_ERROR("DB", "Failed to update queue_state: %s", + sqlite3_errmsg((sqlite3 *) db)); goto error; } @@ -499,7 +499,7 @@ database_queue_set_current_index(volatile sqlite3 *db, int idx) char SQL_GET[LKT_MAX_SQLITE_STATEMENT]; if (idx <= 0) { - LOG_ERROR_SCT("DB", "An idx of %d is invalid, must be >= 0", idx); + LOG_ERROR("DB", "An idx of %d is invalid, must be >= 0", idx); return false; } @@ -535,8 +535,8 @@ database_queue_get_current_file(volatile sqlite3 *db, char filepath[PATH_MAX]) } else { - LOG_ERROR_SCT("DB", "Failed to fetch prev kara: %s", - sqlite3_errmsg((sqlite3 *) db)); + LOG_ERROR("DB", "Failed to fetch prev kara: %s", + sqlite3_errmsg((sqlite3 *) db)); goto error; } @@ -650,7 +650,7 @@ database_queue_list(volatile sqlite3 *db, size_t from, size_t to, goto done; else { - LOG_ERROR_SCT("DB", "Failed: %s", sqlite3_errmsg((sqlite3 *) db)); + LOG_ERROR("DB", "Failed: %s", sqlite3_errmsg((sqlite3 *) db)); break; } } diff --git a/src/database/stickers.c b/src/database/stickers.c index dc37fcbe..bc3bb3dc 100644 --- a/src/database/stickers.c +++ b/src/database/stickers.c @@ -66,7 +66,7 @@ database_sticker_set(volatile sqlite3 *db, const char *type, const char *name, int ret = false; if (__check_type(type)) { - LOG_ERROR_SCT("DB", "Type '%s' is invalid", type); + LOG_ERROR("DB", "Type '%s' is invalid", type); return false; } @@ -97,7 +97,7 @@ database_sticker_delete_specify(volatile sqlite3 *db, const char *type, sqlite3_stmt *stmt; int ret = false; if (__check_type(type)) { - LOG_ERROR_SCT("DB", "Type '%s' is invalid", type); + LOG_ERROR("DB", "Type '%s' is invalid", type); return false; } diff --git a/src/database/update.c b/src/database/update.c index 94ee3ad2..d2fe7e5f 100644 --- a/src/database/update.c +++ b/src/database/update.c @@ -60,7 +60,7 @@ __database_add_kara(volatile sqlite3 *db, const char *filename) /* Metadata */ if (kara_metadata_read(&data, filename) != 0) { - LOG_ERROR_SCT("UPDATE", "Failed to get mdt for the kara '%s'", filename); + LOG_ERROR("UPDATE", "Failed to get mdt for the kara '%s'", filename); return false; } @@ -76,7 +76,7 @@ __database_add_kara(volatile sqlite3 *db, const char *filename) STRTOL(kara_id, id, token, id_len); if (!id_len && STR_MATCH(&token[1], "mkv")) { /* Use the found id, most of the time, normally */ - LOG_INFO_SCT("DB", "Found id '%ld' in kara '%s'", kara_id, filename); + LOG_INFO("DB", "Found id '%ld' in kara '%s'", kara_id, filename); SQLITE_PREPARE(db, stmt, SQL_STMT_WITH_ID, error); SQLITE_BIND_INT(db, stmt, 10, (int) kara_id, error); } else { @@ -94,8 +94,8 @@ __database_add_kara(volatile sqlite3 *db, const char *filename) (sqlite3_bind_text(stmt, 8, data.author_name, -1, 0) != SQLITE_OK) || (sqlite3_bind_int (stmt, 9, data.song_number) != SQLITE_OK) ) { - LOG_ERROR_SCT("DB", "Failed to bind for kara %s: %s", filename, - sqlite3_errmsg((sqlite3 *) db)); + LOG_ERROR("DB", "Failed to bind for kara %s: %s", filename, + sqlite3_errmsg((sqlite3 *) db)); goto error; } SQLITE_STEP_DONE(db, stmt, error); @@ -125,7 +125,7 @@ database_update_set_available(volatile sqlite3 *db, int id) return true; error: sqlite3_finalize(stmt); - LOG_ERROR_SCT("DB", "Failed to set kara %d available", id); + LOG_ERROR("DB", "Failed to set kara %d available", id); return false; } @@ -164,7 +164,7 @@ database_update_add(volatile sqlite3 *db, const char *kara_path, (sqlite3_bind_int (stmt, 10, id) != SQLITE_OK) || (sqlite3_bind_int (stmt, 11, avail) != SQLITE_OK) ) { - LOG_ERROR_SCT("DB", "Failed to bind argument for kara %s: %s", kara_path, sqlite3_errmsg((sqlite3 *) db)); + LOG_ERROR("DB", "Failed to bind argument for kara %s: %s", kara_path, sqlite3_errmsg((sqlite3 *) db)); goto error; } @@ -185,8 +185,8 @@ database_update(volatile sqlite3 *db, const char *kara_dir, int check_timestamp) memset(path, 0, PATH_MAX * sizeof(char)); if (!(d = opendir(kara_dir))) { - LOG_ERROR_SCT("DB", "Failed to open directory '%s': %s", kara_dir, - strerror(errno)); + LOG_ERROR("DB", "Failed to open directory '%s': %s", kara_dir, + strerror(errno)); return false; } @@ -198,8 +198,8 @@ database_update(volatile sqlite3 *db, const char *kara_dir, int check_timestamp) if (dir->d_type == DT_REG) { database_get_update(db, &db_timestamp, NULL, NULL); if (check_timestamp && get_mtime(path) < db_timestamp) { - LOG_INFO_SCT("DB", "Skip update of kara '%s' be cause of " - "timestamps", path); + LOG_INFO("DB", "Skip update of kara '%s' be cause of " + "timestamps", path); continue; } __database_add_kara(db, path); @@ -212,7 +212,7 @@ database_update(volatile sqlite3 *db, const char *kara_dir, int check_timestamp) database_update(db, path, check_timestamp); } - LOG_INFO_SCT("UPADTE", "Passed directory '%s'", kara_dir); + LOG_INFO("UPADTE", "Passed directory '%s'", kara_dir); database_updated(db); closedir(d); return true; @@ -264,8 +264,8 @@ database_get_update(volatile sqlite3 *db, long *timestamp, *current = sqlite3_column_int(stmt, 2); return; error: - LOG_WARN_SCT("DB", "Failed to get informations about the last update: %s", - sqlite3_errmsg((sqlite3 *) db)); + LOG_WARN("DB", "Failed to get informations about the last update: %s", + sqlite3_errmsg((sqlite3 *) db)); } void @@ -282,7 +282,7 @@ database_update_del(volatile sqlite3 *db, int id) SQLITE_PREPARE(db, stmt, SQL, error); SQLITE_BIND_INT(db, stmt, 1, id, error); SQLITE_STEP_DONE(db, stmt, error); - LOG_WARN_SCT("DB", "Deleted kara with id '%d' from database", id); + LOG_WARN("DB", "Deleted kara with id '%d' from database", id); error: return; } diff --git a/src/database/user.c b/src/database/user.c index c39bd88c..1aa06bdb 100644 --- a/src/database/user.c +++ b/src/database/user.c @@ -14,8 +14,8 @@ database_user_authentificate(volatile sqlite3 *db, const char *password) SQLITE_PREPARE(db, stmt, SQL_STMT, error); SQLITE_BIND_TEXT(db, stmt, 1, password, error); SQLITE_STEP_ROW(db, stmt, error); - LOG_INFO_SCT("DB", "User authentification for '%s'", - sqlite3_column_text(stmt, 0)); + LOG_INFO("DB", "User authentification for '%s'", + sqlite3_column_text(stmt, 0)); ret = true; error: sqlite3_finalize(stmt); @@ -33,7 +33,7 @@ database_user_add(volatile sqlite3 *db, const char *username, const char *passwo SQLITE_BIND_TEXT(db, stmt, 1, username, error); SQLITE_BIND_TEXT(db, stmt, 2, password, error); SQLITE_STEP_DONE(db, stmt, error); - LOG_INFO_SCT("DB", "User '%s' successfully added", username); + LOG_INFO("DB", "User '%s' successfully added", username); ret = true; error: sqlite3_finalize(stmt); diff --git a/src/main/lkt.c b/src/main/lkt.c index 1794962d..58471c17 100644 --- a/src/main/lkt.c +++ b/src/main/lkt.c @@ -27,8 +27,8 @@ #include <limits.h> #define LKT_KEY_VALUE_SEP ": \n\t\0" -#define fail_if(cond, msg) { if (cond) { LOG_ERROR_SCT("LKT", "%s", msg); exit(EXIT_FAILURE); } } -#define fail(msg) { LOG_ERROR_SCT("LKT", "%s", msg); exit(EXIT_FAILURE); } +#define fail_if(cond, msg) { if (cond) { LOG_ERROR("LKT", "%s", msg); exit(EXIT_FAILURE); } } +#define fail(msg) { LOG_ERROR("LKT", "%s", msg); exit(EXIT_FAILURE); } #define exit_with_status(sock, buff) { \ read_socket(sock, buff, 2); \ @@ -903,7 +903,7 @@ static struct lkt_cmd_opt options_[] = { static void sigpipe__(int sig) { - LOG_ERROR_SCT("GENERAL", "Exit because of signal sigpipe (%d)", sig); + LOG_ERROR("GENERAL", "Exit because of signal sigpipe (%d)", sig); exit(EXIT_FAILURE); } diff --git a/src/main/server.c b/src/main/server.c index 29ff8e20..726c83ab 100644 --- a/src/main/server.c +++ b/src/main/server.c @@ -66,16 +66,16 @@ main(int argc, char *argv[]) } normal_launch: - LOG_INFO_SCT("GENERAL", "Lektor launched by user %s (shell: %s, home: %s)", - pw->pw_name, pw->pw_shell, pw->pw_dir); + LOG_INFO("GENERAL", "Lektor launched by user %s (shell: %s, home: %s)", + pw->pw_name, pw->pw_shell, pw->pw_dir); if (env_get(LKT_ENV_RESTART)) - LOG_INFO_SCT("GENERAL", "%s", "Lektord has been restarted"); + LOG_INFO("GENERAL", "%s", "Lektord has been restarted"); reg_set(server_reg); mthread_init(); pthread_create(&th, NULL, mthread_main, NULL); if (read_self_exe(exe, PATH_MAX)) - LOG_WARN_SCT("GENERAL", "%s", "Failed to read self executable path, " - "restart may not work"); + LOG_WARN("GENERAL", "%s", "Failed to read self executable path, " + "restart may not work"); executable_name = exe; /* Init the server */ @@ -85,23 +85,23 @@ normal_launch: .kara_prefix = kara_dir, }; if (lkt_queue_new(&srv.queue)) { - LOG_ERROR_SCT("INIT", "%s", "Faield to create server queue"); + LOG_ERROR("INIT", "%s", "Faield to create server queue"); exit(EXIT_FAILURE); } /* Initialize the system. */ if (!database_new(&srv.db)) { - LOG_ERROR_SCT("INIT", "%s", "Failed to init memory db"); + LOG_ERROR("INIT", "%s", "Failed to init memory db"); exit(EXIT_FAILURE); } if (conf_file[0] == '\0' && config_detect_file(conf_file, PATH_MAX)) { - LOG_ERROR_SCT("INIT", "%s", "Failed to find a config file"); + LOG_ERROR("INIT", "%s", "Failed to find a config file"); exit(EXIT_FAILURE); } if (config_new(srv.db, conf_file)) { - LOG_ERROR_SCT("INIT", "%s", "Failed to read the config"); + LOG_ERROR("INIT", "%s", "Failed to read the config"); exit(EXIT_FAILURE); } free(conf_file); @@ -132,7 +132,7 @@ normal_launch: /* Not working -> race condition with player module */ char *env_current = env_get(LKT_ENV_CURRENT); if (env_current && env_current[0] && !STR_MATCH(env_current, "NULL")) { - LOG_INFO_SCT("INIT", "Restart playback from %s", env_current); + LOG_INFO("INIT", "Restart playback from %s", env_current); lkt_queue_send(&srv.queue, lkt_event_play_pos, (void *) (size_t) strtol(env_current, NULL, 0)); } diff --git a/src/mkv/utils.c b/src/mkv/utils.c index 2e219741..cb9fb643 100644 --- a/src/mkv/utils.c +++ b/src/mkv/utils.c @@ -16,7 +16,7 @@ mdtcat(struct kara_metadata *mdt, char **ret) long_length(mdt->song_number); *ret = malloc(sizeof(char) * size); if (!*ret) { - LOG_ERROR_SCT("MKV", "%s", "Out of memory"); + LOG_ERROR("MKV", "%s", "Out of memory"); return; } diff --git a/src/mkv/write.c b/src/mkv/write.c index a3a3975f..0999ac11 100644 --- a/src/mkv/write.c +++ b/src/mkv/write.c @@ -66,14 +66,14 @@ mkvpropedit__(const char *const args[]) if ((pid = fork()) == 0) { if ((fd = open("/dev/null", O_WRONLY | O_TRUNC)) < 0) { - LOG_ERROR_SCT("FORK", "%s", "Can't to open /dev/null " - "in O_WRONLY O_TRUNC"); + LOG_ERROR("FORK", "%s", "Can't to open /dev/null " + "in O_WRONLY O_TRUNC"); return false; } if (dup2(fd, 1) < 0) { - LOG_ERROR_SCT("FORK", "%s", "Failed to duplicate " - "/dev/null to stdout"); + LOG_ERROR("FORK", "%s", "Failed to duplicate " + "/dev/null to stdout"); return false; } @@ -82,21 +82,21 @@ mkvpropedit__(const char *const args[]) } else if (pid < 0) { - LOG_ERROR_SCT("FORK", "Failed to fork: %s\n", strerror(errno)); + LOG_ERROR("FORK", "Failed to fork: %s\n", strerror(errno)); return false; } else { do { if (waitpid(pid, &wstatus, WUNTRACED | WCONTINUED) == -1) { - LOG_ERROR_SCT("FORK", "Failed to wait children: %s", - strerror(errno)); + LOG_ERROR("FORK", "Failed to wait children: %s", + strerror(errno)); return false; } } while (!WIFEXITED(wstatus) && !WIFSIGNALED(wstatus)); if ((status = WEXITSTATUS(wstatus))) { - LOG_ERROR_SCT("FORK", "Children failed with status %d", status); + LOG_ERROR("FORK", "Children failed with status %d", status); return false; } } @@ -118,16 +118,16 @@ kara_metadata_write(struct kara_metadata *mdt, const char *filename, strncat(tmpfilepath, "all:/tmp/lektor.metadata.XXXXXX", PATH_MAX - 1); if ((fd = mkstemp(metadafilepath)) < 0) { - LOG_ERROR_SCT("WRITER", "Failed to create temporary file: %s", - strerror(errno)); + LOG_ERROR("WRITER", "Failed to create temporary file: %s", + strerror(errno)); goto error; } if (dprintf(fd, METADATA_TEMPLATE, mdt->source_name, mdt->song_name, mdt->category, mdt->language, mdt->author_name, mdt->song_type, mdt->song_number) < 0) { - LOG_ERROR_SCT("WRITER", "Failed to write to temporary file: %s", - metadafilepath); + LOG_ERROR("WRITER", "Failed to write to temporary file: %s", + metadafilepath); goto error; } @@ -158,7 +158,7 @@ metadata_from_path(char *const mkvfile, struct kara_metadata *meta) "(.+) - (OP|ED|IS|AMV|VOCA|PV|MV|LIVE)([[:digit:]]*) - (.+)\\.mkv$"; if (!regex_init && regcomp(®ex, rgx, REG_EXTENDED)) { - LOG_ERROR_SCT("MPV", "%s", "Failed to compile regex"); + LOG_ERROR("MPV", "%s", "Failed to compile regex"); goto error; } @@ -176,11 +176,11 @@ metadata_from_path(char *const mkvfile, struct kara_metadata *meta) memcpy(msgbuf, mkvfile + pmatch[7].rm_so, pmatch[7].rm_eo - pmatch[7].rm_so); memcpy(meta->song_name, mkvfile + pmatch[8].rm_so, pmatch[8].rm_eo - pmatch[8].rm_so); } else if (REG_NOMATCH == reti) { - LOG_ERROR_SCT("WRITER", "No match for: %s", mkvfile); + LOG_ERROR("WRITER", "No match for: %s", mkvfile); goto error; } else { regerror(reti, ®ex, msgbuf, sizeof(msgbuf)); - LOG_ERROR_SCT("WRITER", "Failed to execute regex: %s", msgbuf); + LOG_ERROR("WRITER", "Failed to execute regex: %s", msgbuf); goto error; } @@ -204,8 +204,8 @@ metadata_set_directory(const char *kara_dir, const char *mkvpropedit) memset(path, 0, PATH_MAX * sizeof(char)); if (!(d = opendir(kara_dir))) { - LOG_ERROR_SCT("WRITER", "Failed to open directory '%s': %s", kara_dir, - strerror(errno)); + LOG_ERROR("WRITER", "Failed to open directory '%s': %s", kara_dir, + strerror(errno)); return 1; } @@ -224,7 +224,7 @@ metadata_set_directory(const char *kara_dir, const char *mkvpropedit) metadata_set_directory(path, mkvpropedit); } - LOG_INFO_SCT("WRITER", "Passed directory '%s'", kara_dir); + LOG_INFO("WRITER", "Passed directory '%s'", kara_dir); closedir(d); return false; } diff --git a/src/module/module_sdl2.c b/src/module/module_sdl2.c index 0169dfe2..faa121c1 100644 --- a/src/module/module_sdl2.c +++ b/src/module/module_sdl2.c @@ -92,7 +92,7 @@ init_mpv_gl__(mpv_handle *mpv, mpv_render_context **mpv_gl, wakeup_on_mpv_events = SDL_RegisterEvents(1); if (wakeup_on_mpv_render_update == (Uint32) - 1 || wakeup_on_mpv_events == (Uint32) - 1) { - LOG_ERROR_SCT("WINDOW", "%s", "Failed to register event"); + LOG_ERROR("WINDOW", "%s", "Failed to register event"); return 1; } @@ -154,7 +154,7 @@ sdl_thread__(struct poller_thread_arg *arg) while (!sdl2->launched) sched_yield(); - LOG_INFO_SCT("WINDOW", "%s", "Started SDL thread"); + LOG_INFO("WINDOW", "%s", "Started SDL thread"); loop: SDL_WaitEvent(&event); @@ -226,7 +226,7 @@ loop: (uint64_t) str, cmd); } } else - LOG_ERROR_SCT("WINDOW", "Not handled text '%s'", event.text.text); + LOG_ERROR("WINDOW", "Not handled text '%s'", event.text.text); break; default: diff --git a/src/module/module_x11.c b/src/module/module_x11.c index 9c10b1f4..14d7a5ad 100644 --- a/src/module/module_x11.c +++ b/src/module/module_x11.c @@ -154,7 +154,7 @@ lx11_handle(struct module_x11_window *win) // Key press if (event.type == KeyRelease) { - LOG_INFO_SCT("WINDOW", "Release key: 0x%x", event.xkey.keycode); + LOG_INFO("WINDOW", "Release key: 0x%x", event.xkey.keycode); if (event.xkey.keycode == 0x47) XClearWindow(win->master_display, win->master_win); } @@ -190,7 +190,7 @@ module_x11_new(struct lkt_win *const win) memset(x11_win, 0, sizeof(struct module_x11_window)); RETURN_UNLESS(x11_win, "Out of memory", false); RETURN_UNLESS(lx11_new(x11_win), "Can't create X11 window", false); - LOG_INFO_SCT("WINDOW", "%s", "Created the X11 window"); + LOG_INFO("WINDOW", "%s", "Created the X11 window"); } if (x11_win->mpv == NULL) { diff --git a/src/module/mpv.c b/src/module/mpv.c index 3eceb8cf..06763230 100644 --- a/src/module/mpv.c +++ b/src/module/mpv.c @@ -18,7 +18,7 @@ lmpv_free(mpv_handle **ctx) mpv_command(*ctx, cmd); mpv_destroy(*ctx); *ctx = NULL; - LOG_INFO_SCT("WINDOW", "%s", "The mpv context was destroyed"); + LOG_INFO("WINDOW", "%s", "The mpv context was destroyed"); } mpv_handle * @@ -31,13 +31,13 @@ lmpv_prepare(volatile sqlite3 *db) #define MPV_SET_OPTION(opt, value) \ if ((status = mpv_set_option_string(ctx, opt, value)) < 0) { \ - LOG_ERROR_SCT("WINDOW", "Failed to set %s to %s: %s", \ + LOG_ERROR("WINDOW", "Failed to set %s to %s: %s", \ opt, value, mpv_error_string(status)); \ return NULL; \ } #define MPV_SET_FROM_INI(opt, section, key) \ if (!database_config_get_text(db, section, key, _opt, INI_MAX_LINE_LEN)) { \ - LOG_WARN_SCT("WINDOW", "%s", "Failed to get option " \ + LOG_WARN("WINDOW", "%s", "Failed to get option " \ key " in section " section); \ return ctx; \ } \ @@ -74,21 +74,21 @@ lmpv_new(unsigned long int wid, volatile sqlite3 *db) int status; if ((status = mpv_set_property(ctx, "wid", MPV_FORMAT_INT64, &wid)) < 0) { - LOG_ERROR_SCT("WINDOW", "Failed to set wid: %s", mpv_error_string(status)); + LOG_ERROR("WINDOW", "Failed to set wid: %s", mpv_error_string(status)); goto error; } if ((status = mpv_initialize(ctx)) < 0) { - LOG_ERROR_SCT("WINDOW", "Failed to init mpv: %s", mpv_error_string(status)); + LOG_ERROR("WINDOW", "Failed to init mpv: %s", mpv_error_string(status)); goto error; } if (!lmpv_observe_properties(ctx)) { - LOG_ERROR_SCT("WINDOW", "%s", "Failed to observe properties"); + LOG_ERROR("WINDOW", "%s", "Failed to observe properties"); goto error; } - LOG_INFO_SCT("WINDOW", "%s", "Create mpv context"); + LOG_INFO("WINDOW", "%s", "Create mpv context"); return ctx; error: lmpv_free(&ctx); @@ -105,7 +105,7 @@ lmpv_set_volume(mpv_handle *ctx, int vol) safe_snprintf(str, 4, "%d", vol); const char *cmd[] = {"set", "ao-volume", str, NULL}; if ((status = mpv_command_async(ctx, 0, cmd)) < 0) { - LOG_ERROR_SCT("WINDOW", "Failed to execute command: %s", mpv_error_string(status)); + LOG_ERROR("WINDOW", "Failed to execute command: %s", mpv_error_string(status)); return 1; } return 0; @@ -120,11 +120,11 @@ lmpv_load_file(mpv_handle *ctx, const char *file) const char *cmd2[] = { "set", "pause", "0", NULL }; int status; if ((status = mpv_command_async(ctx, 0, cmd1)) < 0) { - LOG_ERROR_SCT("WINDOW", "Failed to add '%s': %s", file, mpv_error_string(status)); + LOG_ERROR("WINDOW", "Failed to add '%s': %s", file, mpv_error_string(status)); return 1; } if ((status = mpv_command_async(ctx, 0, cmd2)) < 0) { - LOG_ERROR_SCT("WINDOW", "Failed to set state to play: %s", mpv_error_string(status)); + LOG_ERROR("WINDOW", "Failed to set state to play: %s", mpv_error_string(status)); return 1; } return 0; @@ -137,7 +137,7 @@ lmpv_toggle_pause(mpv_handle *ctx) const char *cmd[] = {"cycle", "pause", "up", NULL}; int status; if ((status = mpv_command_async(ctx, 0, cmd)) < 0) { - LOG_ERROR_SCT("WINDOW", "Failed issus command: %s", mpv_error_string(status)); + LOG_ERROR("WINDOW", "Failed issus command: %s", mpv_error_string(status)); return 1; } return 0; @@ -214,7 +214,7 @@ loop: break; default: - LOG_WARN_SCT("WINDOW", "Unhandled mpv event '%s'", mpv_event_name(event->event_id)); + LOG_WARN("WINDOW", "Unhandled mpv event '%s'", mpv_event_name(event->event_id)); break; } goto loop; /* A loop without indentation. */ diff --git a/src/module/repo.c b/src/module/repo.c index adcf07d1..c57b2fba 100644 --- a/src/module/repo.c +++ b/src/module/repo.c @@ -169,8 +169,8 @@ __json_sync(struct lkt_repo *const repo, struct json_object **json) res = curl_easy_perform(curl_handle); if (res != CURLE_OK) { - LOG_ERROR_SCT("CURL", "curl_easy_perform failed: %s", - curl_easy_strerror(res)); + LOG_ERROR("CURL", "curl_easy_perform failed: %s", + curl_easy_strerror(res)); free(file.mem); goto err; } @@ -206,8 +206,8 @@ repo_get_id(struct lkt_repo *const repo, const uint64_t id, curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "libcurl-agent/1.0"); if (CURLE_OK != (res = curl_easy_perform(curl_handle))) { - LOG_ERROR_SCT("CURL", "curl_easy_perform failed: %s", - curl_easy_strerror(res)); + LOG_ERROR("CURL", "curl_easy_perform failed: %s", + curl_easy_strerror(res)); free(file.mem); curl_easy_cleanup(curl_handle); return 1; @@ -219,12 +219,12 @@ repo_get_id(struct lkt_repo *const repo, const uint64_t id, jobj = json_tokener_parse(file.mem); if (json_object_object_get_ex(jobj, "message", &field)) { - LOG_ERROR_SCT("REPO", "Kara with id %lu not found, message is: %s", id, - json_object_get_string(field)); + LOG_ERROR("REPO", "Kara with id %lu not found, message is: %s", id, + json_object_get_string(field)); goto err; } - LOG_INFO_SCT("REPO", "Got kara with id %lu", id); + LOG_INFO("REPO", "Got kara with id %lu", id); err |= safe_json_get_string(jobj, "song_name", mdt->song_name, LEKTOR_TAG_MAX); err |= safe_json_get_string(jobj, "source_name", mdt->source_name, LEKTOR_TAG_MAX); err |= safe_json_get_string(jobj, "category", mdt->category, LEKTOR_TAG_MAX); @@ -251,11 +251,11 @@ __download_kara(const char *url, const char *path, int override) retest: if (fd < 0) { if (errno == EEXIST && ! override) - LOG_ERROR_SCT("REPO", "File '%s' already exists", path); + LOG_ERROR("REPO", "File '%s' already exists", path); else if (errno == EEXIST && override) { if (unlink(path)) { - LOG_ERROR_SCT("REPO", "Failed to unlink file '%s'", path); + LOG_ERROR("REPO", "Failed to unlink file '%s'", path); return 1; } @@ -265,7 +265,7 @@ retest: } else - LOG_ERROR_SCT("REPO", "Could not open file '%s'", path); + LOG_ERROR("REPO", "Could not open file '%s'", path); return 1; } @@ -282,8 +282,8 @@ retest: curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "libcurl-agent/1.0"); if (CURLE_OK != (ret = curl_easy_perform(curl_handle))) { - LOG_ERROR_SCT("CURL", "curl_easy_perform failed: %s", - curl_easy_strerror(ret)); + LOG_ERROR("CURL", "curl_easy_perform failed: %s", + curl_easy_strerror(ret)); goto err; } @@ -302,7 +302,7 @@ repo_download_id_sync(struct lkt_repo *const repo, const uint64_t id, char url[URL_MAX_LEN]; if (repo_get_id(repo, id, mdt_ret ? mdt_ret : &mdt)) { - LOG_ERROR_SCT("REPO", "%s", "Failed to get kara metadata from kurisu"); + LOG_ERROR("REPO", "%s", "Failed to get kara metadata from kurisu"); return 1; } @@ -310,14 +310,14 @@ repo_download_id_sync(struct lkt_repo *const repo, const uint64_t id, safe_snprintf(url, URL_MAX_LEN, repo->get_id_file, id); if (__download_kara(url, kara_path, false)) { - LOG_ERROR_SCT("REPO", "Failed to download kara '%s' with url '%s'", - kara_path, url); + LOG_ERROR("REPO", "Failed to download kara '%s' with url '%s'", + kara_path, url); return 1; } if (repo->db && !database_update_add((sqlite3 *) repo->db, kara_path, mdt_ret ? mdt_ret : &mdt, id, true)) { - LOG_ERROR_SCT("REPO", "%s", "Failed to add kara to database"); + LOG_ERROR("REPO", "%s", "Failed to add kara to database"); return 1; } @@ -345,7 +345,7 @@ __handle_got_json(volatile sqlite3 *db, struct lkt_repo *repo, mkvpropedit, PATH_MAX - 1), "Can't get the mkvpropedit executable path", NOTHING); - LOG_INFO_SCT("REPO", "Starting to process json for repo %s", repo->name); + LOG_INFO("REPO", "Starting to process json for repo %s", repo->name); for (i = 0; i < len; ++i) { kara_json = json_object_array_get_idx(json, i); err = 0; @@ -374,7 +374,7 @@ __handle_got_json(volatile sqlite3 *db, struct lkt_repo *repo, err |= safe_json_get_string(kara_json, "author_name", kara.mdt.author_name, LEKTOR_TAG_MAX); err |= safe_json_get_string(kara_json, "song_type", kara.mdt.song_type, LEKTOR_TAG_MAX); if (err || safe_json_get_int32(kara_json, "song_number", &kara.mdt.song_number)) { - LOG_WARN_SCT("REPO", "Json is invalid for kara '%ld', skip it", kara.id); + LOG_WARN("REPO", "Json is invalid for kara '%ld', skip it", kara.id); continue; } @@ -387,16 +387,16 @@ __handle_got_json(volatile sqlite3 *db, struct lkt_repo *repo, ! kara_metadata_equals(&kara.mdt, kara.filename)) { database_update_touch(db, kara.id); database_update_set_available(db, kara.id); - LOG_INFO_SCT("REPO", "Ignore kara '%ld' with path '%s'", - kara.id, kara.filename); + LOG_INFO("REPO", "Ignore kara '%ld' with path '%s'", + kara.id, kara.filename); continue; } current_id = 0; database_queue_current_kara(db, NULL, ¤t_id); if (current_id == (int) kara.id) { - LOG_WARN_SCT("REPO", "Update currently playing kara %d, skip it", - current_id); + LOG_WARN("REPO", "Update currently playing kara %d, skip it", + current_id); char *current_path = safe_malloc(PATH_MAX * sizeof(char)); database_queue_skip_current(db, current_path); srv->win.load_file(&srv->win, current_path); @@ -404,33 +404,33 @@ __handle_got_json(volatile sqlite3 *db, struct lkt_repo *repo, } if (!database_update_add(db, kara.filename, &kara.mdt, kara.id, false)) { - LOG_ERROR_SCT("REPO", "Could not add unavailable kara %ld to db", - kara.id); + LOG_ERROR("REPO", "Could not add unavailable kara %ld to db", + kara.id); continue; } safe_snprintf(url, URL_MAX_LEN, repo->get_id_file, kara.id); if (__download_kara(url, kara.filename, true)) { - LOG_WARN_SCT("REPO", "Could not download kara %ld at path '%s'", - kara.id, kara.filename); + LOG_WARN("REPO", "Could not download kara %ld at path '%s'", + kara.id, kara.filename); continue; } if (kara_metadata_write(&kara.mdt, kara.filename, mkvpropedit)) { - LOG_WARN_SCT("REPO", "Could not write metadata to kara '%ld' with " - "path '%s'", kara.id, kara.filename); + LOG_WARN("REPO", "Could not write metadata to kara '%ld' with " + "path '%s'", kara.id, kara.filename); continue; } if (!database_update_set_available(db, kara.id)) { - LOG_WARN_SCT("REPO", "Could not set kara %ld available", kara.id); + LOG_WARN("REPO", "Could not set kara %ld available", kara.id); continue; } database_stamp(db); - LOG_INFO_SCT("REPO", "Added kara %ld from repo %s, filepath is %s", - kara.id, repo->name, kara.filename); + LOG_INFO("REPO", "Added kara %ld from repo %s, filepath is %s", + kara.id, repo->name, kara.filename); } } @@ -454,14 +454,14 @@ __repo_get_all_id_async(void *arg) { struct json_object *json; struct lkt_repo *const repo = arg; - LOG_INFO_SCT("REPO", "Download kara list from %s (%s), directory is %s", - repo->name, repo->get_all_json, repo->kara_dir); + LOG_INFO("REPO", "Download kara list from %s (%s), directory is %s", + repo->name, repo->get_all_json, repo->kara_dir); __json_sync(repo, &json); __handle_got_json(repo->db, repo, json); - LOG_INFO_SCT("REPO", "%s", "Finished to download and insert kara list"); + LOG_INFO("REPO", "%s", "Finished to download and insert kara list"); json_object_put(json); __handle_deleted_kara(repo->db); - LOG_INFO_SCT("REPO", "%s", "Finished to deal with deleted kara"); + LOG_INFO("REPO", "%s", "Finished to deal with deleted kara"); database_updated(repo->db); return NULL; } diff --git a/src/mthread/mthread.c b/src/mthread/mthread.c index 561a779a..3cd1d0ac 100644 --- a/src/mthread/mthread.c +++ b/src/mthread/mthread.c @@ -185,7 +185,7 @@ mthread_idle_task(void *arg) done = 0; } } - LOG_INFO_SCT("SCHEDULER", "Virtual processor %d started", vp->rank); + LOG_INFO("SCHEDULER", "Virtual processor %d started", vp->rank); while (1) __mthread_yield(vp); not_implemented(); @@ -256,14 +256,14 @@ static void mthread_start_thread(void *arg) { struct mthread_s *mctx = (struct mthread_s *)arg; - LOG_INFO_SCT("THREAD", "Thread %p started", arg); + LOG_INFO("THREAD", "Thread %p started", arg); mthread_virtual_processor_t *vp = mthread_get_vp(); __mthread_yield(vp); mctx->res = mctx->__start_routine(mctx->arg); mctx->status = ZOMBIE; - LOG_INFO_SCT("THREAD", "Thread %p ended (%d)", arg, vp->rank); + LOG_INFO("THREAD", "Thread %p ended (%d)", arg, vp->rank); if (mctx->detached) { - LOG_INFO_SCT("THREAD", "Thread %p (vp: %d) was detached, join it", arg, vp->rank); + LOG_INFO("THREAD", "Thread %p (vp: %d) was detached, join it", arg, vp->rank); mthread_join(mctx, NULL); } vp = mthread_get_vp(); @@ -277,7 +277,7 @@ __mthread_lib_init(long i) { mthread_init_lib(i); virtual_processors[0].state = 1; - LOG_INFO_SCT("THREAD", "%s", "library started"); + LOG_INFO("THREAD", "%s", "library started"); } void @@ -318,7 +318,7 @@ mthread_create(mthread_t *__threadp, const mthread_attr_t __attr, void *(*__star mctx->detached = DETACHED_FREE; } - LOG_INFO_SCT("THREAD INIT", "Create thread %p", (void *) mctx); + LOG_INFO("THREAD INIT", "Create thread %p", (void *) mctx); mctx->arg = __arg; mctx->__start_routine = __start_routine; mthread_mctx_set(mctx, mthread_start_thread, stack, MTHREAD_DEFAULT_STACK, mctx); @@ -352,7 +352,7 @@ mthread_exit(void *__retval) struct mthread_s *mctx = (struct mthread_s *) vp->current; mctx->res = __retval; mctx->status = ZOMBIE; - LOG_INFO_SCT("THREAD END", "Thread %p exited", (void *) mctx); + LOG_INFO("THREAD END", "Thread %p exited", (void *) mctx); __mthread_yield(vp); } @@ -362,7 +362,7 @@ mthread_exit(void *__retval) int mthread_join(mthread_t __th, void **__thread_return) { - LOG_INFO_SCT("THREAD END", "Join thread %p", (void *) __th); + LOG_INFO("THREAD END", "Join thread %p", (void *) __th); while (__th->status != ZOMBIE) mthread_yield(); @@ -371,7 +371,7 @@ mthread_join(mthread_t __th, void **__thread_return) *__thread_return = (void *)__th->res; __mthread_clear_keys(&__th); - LOG_INFO_SCT("THREAD END", "Thread %p joined", (void *) __th); + LOG_INFO("THREAD END", "Thread %p joined", (void *) __th); mthread_insert_last(__th, &(joined_list)); return 0; } @@ -380,6 +380,6 @@ void mthread_yield() { mthread_virtual_processor_t *vp = mthread_get_vp(); - LOG_INFO_SCT("THREAD YIELD", "Thread %p yield", (void *) vp->current); + LOG_INFO("THREAD YIELD", "Thread %p yield", (void *) vp->current); __mthread_yield(vp); } diff --git a/src/mthread/mthread_cond.c b/src/mthread/mthread_cond.c index 7857572b..1956f442 100644 --- a/src/mthread/mthread_cond.c +++ b/src/mthread/mthread_cond.c @@ -16,7 +16,7 @@ mthread_cond_init(mthread_cond_t *__cond, const mthread_condattr_t *__cond_attr) __cond->lock = 0; __cond->list = safe_malloc(sizeof(struct mthread_list_s)); memset(__cond->list, 0, sizeof(struct mthread_list_s)); - LOG_INFO_SCT("MTHREAD", "%s", "Successfully created a condition"); + LOG_INFO("MTHREAD", "%s", "Successfully created a condition"); return 0; } @@ -43,12 +43,12 @@ mthread_cond_signal(mthread_cond_t *__cond) vp = mthread_get_vp(); first->status = RUNNING; mthread_insert_last(first, &(vp->ready_list)); - LOG_INFO_SCT("MTHREAD", "Wake up the thread %p from the thread %p", - (void *) first, (void *) self); + LOG_INFO("MTHREAD", "Wake up the thread %p from the thread %p", + (void *) first, (void *) self); ret = 0; } else - LOG_INFO_SCT("MTHREAD", "No thread to wake up found from the thread %p", - (void *) self); + LOG_INFO("MTHREAD", "No thread to wake up found from the thread %p", + (void *) self); mthread_spinlock_unlock(&__cond->lock); return ret; @@ -66,8 +66,8 @@ mthread_cond_broadcast(mthread_cond_t *__cond) first = mthread_remove_first(__cond->list); vp = mthread_get_vp(); first->status = RUNNING; - LOG_INFO_SCT("MTHREAD", "Wake up the thread %p from the thread %p", - (void *) first, (void *) self); + LOG_INFO("MTHREAD", "Wake up the thread %p from the thread %p", + (void *) first, (void *) self); mthread_insert_last(first, &(vp->ready_list)); } @@ -87,15 +87,15 @@ mthread_cond_wait(mthread_cond_t *__cond, mthread_mutex_t *__mutex) self->status = BLOCKED; mthread_mutex_unlock(__mutex); - LOG_ERROR_SCT("MTHREAD", "Waiting in condition for thread %p", - (void *) self); + LOG_ERROR("MTHREAD", "Waiting in condition for thread %p", + (void *) self); vp->p = &__cond->lock; mthread_yield(); mthread_mutex_lock(__mutex); - LOG_ERROR_SCT("MTHREAD", "Waike up in condition for thread %p", - (void *) self); + LOG_ERROR("MTHREAD", "Waike up in condition for thread %p", + (void *) self); return 0; } diff --git a/src/mthread/mthread_key.c b/src/mthread/mthread_key.c index 41073ead..96d650dd 100644 --- a/src/mthread/mthread_key.c +++ b/src/mthread/mthread_key.c @@ -92,13 +92,13 @@ mthread_key_delete(mthread_key_t __key) if (!it) { errno = EINVAL; - LOG_ERROR_SCT("MTHREAD", "Key %u not found", __key); + LOG_ERROR("MTHREAD", "Key %u not found", __key); goto end; } if (it->destr) { - LOG_INFO_SCT("MTHREAD", "Call function on data at %p", - (void *) it->spec); + LOG_INFO("MTHREAD", "Call function on data at %p", + (void *) it->spec); it->destr((void *) it->spec); } @@ -110,7 +110,7 @@ mthread_key_delete(mthread_key_t __key) key_table = it->next; free(it); - LOG_INFO_SCT("MTHREAD", "Deleted key %u successfully", __key); + LOG_INFO("MTHREAD", "Deleted key %u successfully", __key); /* End of the function, simply returns. */ end: mthread_spinlock_unlock(&lock); @@ -129,7 +129,7 @@ mthread_setspecific(mthread_key_t __key, const void *__pointer) if (!it) { errno = EINVAL; - LOG_ERROR_SCT("MTHREAD", "Key %u not found", __key); + LOG_ERROR("MTHREAD", "Key %u not found", __key); goto end; } @@ -153,7 +153,7 @@ mthread_getspecific(mthread_key_t __key) if (!it) { errno = EINVAL; - LOG_ERROR_SCT("MTHREAD", "Key %u not found", __key); + LOG_ERROR("MTHREAD", "Key %u not found", __key); goto end; } diff --git a/src/mthread/mthread_mutex.c b/src/mthread/mthread_mutex.c index 3170bb64..beb344ba 100644 --- a/src/mthread/mthread_mutex.c +++ b/src/mthread/mthread_mutex.c @@ -18,7 +18,7 @@ mthread_mutex_init(mthread_mutex_t *__mutex, const mthread_mutexattr_t *__mutex_ __mutex->list->last = NULL; __mutex->nb_thread = 0; __mutex->lock = 0; - LOG_INFO_SCT("MTHREAD", "%s", "MUTEX initialized"); + LOG_INFO("MTHREAD", "%s", "MUTEX initialized"); return 0; } @@ -58,7 +58,7 @@ mthread_mutex_trylock(mthread_mutex_t *__mutex) } mthread_spinlock_unlock(&__mutex->lock); - LOG_WARN_SCT("MTHREAD", "%s", "MUTEX busy"); + LOG_WARN("MTHREAD", "%s", "MUTEX busy"); retval = EBUSY; end: diff --git a/src/net/listen.c b/src/net/listen.c index 332edcb2..93be3cbf 100644 --- a/src/net/listen.c +++ b/src/net/listen.c @@ -126,13 +126,13 @@ static void send_status(struct lkt_state *srv, size_t c, int status, const char *cmd_name) { if (!status) { - LOG_INFO_SCT("COMMAND", "Command '%s'", cmd_name); + LOG_INFO("COMMAND", "Command '%s'", cmd_name); send_ok(srv, c); } else { if (status == 2) - LOG_INFO_SCT("COMMAND", "Unknown command '%s'", cmd_name); + LOG_INFO("COMMAND", "Unknown command '%s'", cmd_name); else - LOG_INFO_SCT("COMMAND", "Command failed '%s'", cmd_name); + LOG_INFO("COMMAND", "Command failed '%s'", cmd_name); send_ack(srv, c, cmd_name); } } @@ -288,8 +288,8 @@ handle_simple_command(struct lkt_state *srv, size_t c, struct lkt_command cmd) continuation = lkt_get_continuation(srv, c); if (continuation > 0) { - LOG_INFO_SCT("NETWORK", "Client should continue from '%d'", - continuation); + LOG_INFO("NETWORK", "Client should continue from '%d'", + continuation); send_continue(srv, c, continuation); } send_status(srv, c, err, cmd.name); @@ -337,7 +337,7 @@ handle_command(struct lkt_state *srv, size_t i, struct lkt_command cmd) else err = handle_simple_command(srv, i, cmd); - LOG_INFO_SCT("COMMAND", "Command result '%s' -> %d", cmd.name, err); + LOG_INFO("COMMAND", "Command result '%s' -> %d", cmd.name, err); return err; } @@ -409,8 +409,8 @@ handle_outgoing_data(struct lkt_state *srv, size_t c) return 0; } if (errno == EPIPE) { - LOG_WARN_SCT("NETWORK", "Client %ld is out, free all its " - "messages", c); + LOG_WARN("NETWORK", "Client %ld is out, free all its " + "messages", c); handle_disconnected_client(srv, i); } return -1; @@ -481,21 +481,21 @@ failure: if (fd < 0) { if (host) - LOG_ERROR_SCT("NETWORK", "Failed to bind to %s:%s", host, port); + LOG_ERROR("NETWORK", "Failed to bind to %s:%s", host, port); else - LOG_ERROR_SCT("NETWORK", "Failed to bind to port %s", port); + LOG_ERROR("NETWORK", "Failed to bind to port %s", port); return -1; } if (listen(fd, LKT_BACKLOG) < 0) { - LOG_ERROR_SCT("NETWORK", "Failed to listen: %s", strerror(errno)); + LOG_ERROR("NETWORK", "Failed to listen: %s", strerror(errno)); return -1; } if (host) - LOG_INFO_SCT("NETWORK", "Listening on %s:%s", host, port); + LOG_INFO("NETWORK", "Listening on %s:%s", host, port); else - LOG_INFO_SCT("NETWORK", "Listening on port %s", port); + LOG_INFO("NETWORK", "Listening on port %s", port); return fd; } @@ -520,8 +520,8 @@ accept_all(int listen_fd, struct pollfd *fds, size_t fds_max, size_t *fds_len) } if (*fds_len == fds_max) { - LOG_ERROR_SCT("NETWORK", "Maximum number '%ld' of file descriptors" - " reached", fds_max); + LOG_ERROR("NETWORK", "Maximum number '%ld' of file descriptors" + " reached", fds_max); break; } @@ -537,7 +537,7 @@ accept_all(int listen_fd, struct pollfd *fds, size_t fds_max, size_t *fds_len) char *host = inet_ntoa(peer_addr.sin_addr); uint16_t port = htons(peer_addr.sin_port); - LOG_WARN_SCT("NETWORK", "New connection from %s:%d", host, port); + LOG_WARN("NETWORK", "New connection from %s:%d", host, port); fds->fd = fd; fds->events = POLLIN; @@ -585,7 +585,7 @@ handle_network_events(struct lkt_state *srv) srv->fds[i].fd = -1; srv->fds[i].revents &= ~ (POLLHUP | POLLERR); handle_disconnected_client(srv, i); - LOG_WARN_SCT("NETWORK", "Client %ld is out", i); + LOG_WARN("NETWORK", "Client %ld is out", i); continue; } if (srv->fds[i].revents & POLLIN) { @@ -611,7 +611,7 @@ handle_network_events(struct lkt_state *srv) if (srv->fds[i].fd > 0) continue; - LOG_WARN_SCT("NETWORK", "Connection closed by client %ld", i); + LOG_WARN("NETWORK", "Connection closed by client %ld", i); srv->fds[i] = srv->fds[srv->fds_len - 1]; srv->clients[i - 1] = srv->clients[srv->fds_len - 2]; srv->fds_len--; @@ -676,8 +676,8 @@ handle_idle_events(struct lkt_state *srv) strncat(msg->data, "message ", LKT_MESSAGE_MAX - 1); msg->data_len = strlen(msg->data); - LOG_INFO_SCT("COMMAND", "Sending '%s' (len: %ld) to client %ld", - msg->data, msg->data_len, i); + LOG_INFO("COMMAND", "Sending '%s' (len: %ld) to client %ld", + msg->data, msg->data_len, i); msg->data[msg->data_len - 1] = '\n'; msg->data[msg->data_len] = '\0'; lkt_state_send(srv, i, msg); diff --git a/src/reg.c b/src/reg.c index b8ca40d0..c0ba8596 100644 --- a/src/reg.c +++ b/src/reg.c @@ -24,13 +24,13 @@ reg_pick(const char *file, void **handle, const char *symbol) goto use_reg; /* Use dlsym */ - LOG_INFO_SCT("REG", "Using dlfcn to find %s", symbol); + LOG_INFO("REG", "Using dlfcn to find %s", symbol); char *error; *handle = dlopen(file, RTLD_NOW); if (NULL == *handle) { - LOG_ERROR_SCT("REG", "libdl error in dlopen on file '%s': %s", - file, dlerror()); + LOG_ERROR("REG", "libdl error in dlopen on file '%s': %s", + file, dlerror()); return NULL; } @@ -38,8 +38,8 @@ reg_pick(const char *file, void **handle, const char *symbol) void *sym = dlsym(*handle, symbol); if ((error = dlerror()) != NULL) { - LOG_ERROR_SCT("REG", "libdl error in dlsym on file '%s': %s\n", - file, error); + LOG_ERROR("REG", "libdl error in dlsym on file '%s': %s\n", + file, error); return NULL; } @@ -47,7 +47,7 @@ reg_pick(const char *file, void **handle, const char *symbol) /* Read the reg */ use_reg: - LOG_INFO_SCT("REG", "Using the reg structure to find %s", symbol); + LOG_INFO("REG", "Using the reg structure to find %s", symbol); for (i = 0; reg[i].name && reg[i].func; ++i) if (STR_MATCH(reg[i].name, symbol)) return *(void **) ®[i].func; @@ -77,8 +77,8 @@ load_so(const char *const mod_path, const char *const mod_init, void *mod, if (module_set_function) return module_set_function(mod, srv, handle); else { - LOG_ERROR_SCT("LOAD", "Failed to find init symbol %s " - "in file %s", mod_init, mod_path); + LOG_ERROR("LOAD", "Failed to find init symbol %s " + "in file %s", mod_init, mod_path); return 1; } } @@ -90,14 +90,14 @@ load_module_by_name(struct lkt_state *srv, const char *name, void *mod) /* When, don't mind if its not here */ if (!database_config_get_text(srv->db, name, "path", mod_path, PATH_MAX)) { - LOG_WARN_SCT("CONFIG", "No setting 'path' in section '%s'", name); + LOG_WARN("CONFIG", "No setting 'path' in section '%s'", name); mod_path[0] = '\0'; } if (!database_config_get_text(srv->db, name, "load_function", mod_load, INI_MAX_LINE_LEN)) { - LOG_ERROR_SCT("CONFIG", "Module named %s is incomplete or " - "is not defined in config file", name); + LOG_ERROR("CONFIG", "Module named %s is incomplete or " + "is not defined in config file", name); return 1; } diff --git a/src/thread.c b/src/thread.c index 6c888d9a..b63f0fb4 100644 --- a/src/thread.c +++ b/src/thread.c @@ -46,15 +46,15 @@ poller_new(struct poller_thread *th, void *(*func)(struct poller_thread_arg *), __args->arg->self = th; if (pthread_create(&(th->th), NULL, __start, __args)) { - LOG_ERROR_SCT("THREAD", "%s", "Failed to create a poller thread"); + LOG_ERROR("THREAD", "%s", "Failed to create a poller thread"); return 1; } - LOG_INFO_SCT("THREAD", "%s", "Create a new poller thread"); + LOG_INFO("THREAD", "%s", "Create a new poller thread"); return 0; out_of_memory: - LOG_ERROR_SCT("MEMORY", "%s", "Out of memory"); + LOG_ERROR("MEMORY", "%s", "Out of memory"); stack_free(&th_.input); stack_free(&th_.output); return 1; @@ -66,11 +66,11 @@ poller_join(struct poller_thread *th, void **ret) int sta = pthread_join(th->th, ret); if (sta) - LOG_ERROR_SCT("THREAD", "%s", "Failed to join thread"); + LOG_ERROR("THREAD", "%s", "Failed to join thread"); stack_free(&th->input); stack_free(&th->output); - LOG_WARN_SCT("THREAD", "%s", "Thread joined"); + LOG_WARN("THREAD", "%s", "Thread joined"); memset(th, 0, sizeof(struct poller_thread)); return sta; diff --git a/src/uri.c b/src/uri.c index 471e2a56..82731d39 100644 --- a/src/uri.c +++ b/src/uri.c @@ -113,8 +113,8 @@ __lkt_to_str(struct lkt_uri *uri, char *ret, size_t len) safe_snprintf(ret, len, "search=%s", (char *) uri->value); break; default: - LOG_ERROR_SCT("URI", "type %d may not be supported by kurisu, " - "generate an error", uri->type); + LOG_ERROR("URI", "type %d may not be supported by kurisu, " + "generate an error", uri->type); return 1; } -- GitLab