Skip to content

Commit

Permalink
cleanup: Align internal logger with external on type of source line.
Browse files Browse the repository at this point in the history
We use `uint32_t` everywhere now. It's easier that way, and line numbers
are never negative.
  • Loading branch information
iphydf committed Dec 28, 2024
1 parent 2e5d814 commit 7f33983
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions auto_tests/auto_test_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,9 +444,9 @@ void print_debug_log(Tox *m, Tox_Log_Level level, const char *file, uint32_t lin
}
}

void print_debug_logger(void *context, Logger_Level level, const char *file, int line, const char *func, const char *message, void *userdata)
void print_debug_logger(void *context, Logger_Level level, const char *file, uint32_t line, const char *func, const char *message, void *userdata)
{
print_debug_log(nullptr, (Tox_Log_Level) level, file, (uint32_t) line, func, message, userdata);
print_debug_log(nullptr, (Tox_Log_Level) level, file, line, func, message, userdata);
}

Tox *tox_new_log_lan(struct Tox_Options *options, Tox_Err_New *err, void *log_user_data, bool lan_discovery)
Expand Down
2 changes: 1 addition & 1 deletion auto_tests/auto_test_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void print_debug_log(Tox *m, Tox_Log_Level level, const char *file, uint32_t lin
const char *message, void *user_data);

// Use this function when setting the log callback on a Logger object
void print_debug_logger(void *context, Logger_Level level, const char *file, int line,
void print_debug_logger(void *context, Logger_Level level, const char *file, uint32_t line,
const char *func, const char *message, void *userdata);

Tox *tox_new_log(struct Tox_Options *options, Tox_Err_New *err, void *log_user_data);
Expand Down
2 changes: 1 addition & 1 deletion other/DHT_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ static const char *strlevel(Logger_Level level)
}
}

static void print_log(void *context, Logger_Level level, const char *file, int line,
static void print_log(void *context, Logger_Level level, const char *file, uint32_t line,
const char *func, const char *message, void *userdata)
{
fprintf(stderr, "[%s] %s:%d(%s) %s\n", strlevel(level), file, line, func, message);
Expand Down
4 changes: 2 additions & 2 deletions other/bootstrap_daemon/src/tox-bootstrapd.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,10 @@ static LOG_LEVEL logger_level_to_log_level(Logger_Level level)
}
}

static void toxcore_logger_callback(void *context, Logger_Level level, const char *file, int line,
static void toxcore_logger_callback(void *context, Logger_Level level, const char *file, uint32_t line,
const char *func, const char *message, void *userdata)
{
log_write(logger_level_to_log_level(level), "%s:%d(%s) %s\n", file, line, func, message);
log_write(logger_level_to_log_level(level), "%s:%u(%s) %s\n", file, line, func, message);
}

static volatile sig_atomic_t caught_signal = 0;
Expand Down
2 changes: 1 addition & 1 deletion toxcore/logger.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void logger_callback_log(Logger *log, logger_cb *function, void *context, void *
log->userdata = userdata;
}

void logger_write(const Logger *log, Logger_Level level, const char *file, int line, const char *func,
void logger_write(const Logger *log, Logger_Level level, const char *file, uint32_t line, const char *func,
const char *format, ...)
{
if (log == nullptr) {
Expand Down
4 changes: 2 additions & 2 deletions toxcore/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ typedef enum Logger_Level {

typedef struct Logger Logger;

typedef void logger_cb(void *context, Logger_Level level, const char *file, int line,
typedef void logger_cb(void *context, Logger_Level level, const char *file, uint32_t line,
const char *func, const char *message, void *userdata);

/**
Expand Down Expand Up @@ -66,7 +66,7 @@ void logger_callback_log(Logger *log, logger_cb *function, void *context, void *
*/
non_null(3, 5, 6) nullable(1) GNU_PRINTF(6, 7)
void logger_write(
const Logger *log, Logger_Level level, const char *file, int line, const char *func,
const Logger *log, Logger_Level level, const char *file, uint32_t line, const char *func,
const char *format, ...);

/* @brief Terminate the program with a signal. */
Expand Down
2 changes: 1 addition & 1 deletion toxcore/tox.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ struct Tox_Userdata {

static logger_cb tox_log_handler;
non_null(1, 3, 5, 6) nullable(7)
static void tox_log_handler(void *context, Logger_Level level, const char *file, int line, const char *func,
static void tox_log_handler(void *context, Logger_Level level, const char *file, uint32_t line, const char *func,
const char *message, void *userdata)
{
Tox *tox = (Tox *)context;
Expand Down

0 comments on commit 7f33983

Please sign in to comment.