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 Jan 12, 2025
1 parent e9bf524 commit 73be7d4
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 16 deletions.
22 changes: 22 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ workflows:
circleci:
jobs:
- bazel-asan
- bazel-dbg
- bazel-opt
- clang-analyze
- cpplint
- static-analysis
Expand All @@ -23,6 +25,26 @@ jobs:
- run: .circleci/bazel-test
//c-toxcore/...

bazel-dbg:
working_directory: /tmp/cirrus-ci-build
docker:
- image: toxchat/toktok-stack:latest-debug

steps:
- checkout
- run: .circleci/bazel-test
//c-toxcore/...

bazel-opt:
working_directory: /tmp/cirrus-ci-build
docker:
- image: toxchat/toktok-stack:latest-release

steps:
- checkout
- run: .circleci/bazel-test
//c-toxcore/...

static-analysis:
working_directory: ~/work
docker:
Expand Down
10 changes: 5 additions & 5 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
bazel-opt_task:
timeout_in: 5m
timeout_in: 10m
container:
image: toxchat/toktok-stack:latest-release
cpu: 2
cpu: 8
memory: 2G
configure_script:
- git submodule update --init --recursive
Expand All @@ -18,10 +18,10 @@ bazel-opt_task:
-//c-toxcore/auto_tests:tcp_relay_test # Cirrus doesn't allow external network connections.

bazel-dbg_task:
timeout_in: 5m
timeout_in: 10m
container:
image: toxchat/toktok-stack:latest-debug
cpu: 2
cpu: 8
memory: 2G
configure_script:
- git submodule update --init --recursive
Expand All @@ -36,7 +36,7 @@ bazel-dbg_task:
-//c-toxcore/auto_tests:tcp_relay_test # Cirrus doesn't allow external network connections.

bazel-msan_task:
timeout_in: 5m
timeout_in: 10m
container:
image: toxchat/toktok-stack:latest-msan
cpu: 2
Expand Down
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
4 changes: 2 additions & 2 deletions other/DHT_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ 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);
fprintf(stderr, "[%s] %s:%u(%s) %s\n", strlevel(level), file, line, func, message);
}

int main(int argc, char *argv[])
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 73be7d4

Please sign in to comment.