Skip to content

Commit c834472

Browse files
committed
refactor: Move tox_log_level out into its own file.
Perhaps we can reuse it in the logger.
1 parent 8799bea commit c834472

File tree

14 files changed

+116
-59
lines changed

14 files changed

+116
-59
lines changed

BUILD.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ genrule(
1010
"//c-toxcore/toxcore:tox.h",
1111
"//c-toxcore/toxcore:tox_dispatch.h",
1212
"//c-toxcore/toxcore:tox_events.h",
13+
"//c-toxcore/toxcore:tox_log_level.h",
1314
"//c-toxcore/toxcore:tox_options.h",
1415
"//c-toxcore/toxcore:tox_private.h",
1516
"//c-toxcore/toxencryptsave:toxencryptsave.h",
@@ -19,6 +20,7 @@ genrule(
1920
"tox/tox.h",
2021
"tox/tox_dispatch.h",
2122
"tox/tox_events.h",
23+
"tox/tox_log_level.h",
2224
"tox/tox_options.h",
2325
"tox/tox_private.h",
2426
"tox/toxencryptsave.h",
@@ -28,6 +30,7 @@ genrule(
2830
cp $(location //c-toxcore/toxcore:tox.h) $(GENDIR)/c-toxcore/tox/tox.h
2931
cp $(location //c-toxcore/toxcore:tox_dispatch.h) $(GENDIR)/c-toxcore/tox/tox_dispatch.h
3032
cp $(location //c-toxcore/toxcore:tox_events.h) $(GENDIR)/c-toxcore/tox/tox_events.h
33+
cp $(location //c-toxcore/toxcore:tox_log_level.h) $(GENDIR)/c-toxcore/tox/tox_log_level.h
3134
cp $(location //c-toxcore/toxcore:tox_options.h) $(GENDIR)/c-toxcore/tox/tox_options.h
3235
cp $(location //c-toxcore/toxcore:tox_private.h) $(GENDIR)/c-toxcore/tox/tox_private.h
3336
cp $(location //c-toxcore/toxencryptsave:toxencryptsave.h) $(GENDIR)/c-toxcore/tox/toxencryptsave.h

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,13 +341,15 @@ set(toxcore_SOURCES
341341
toxcore/timed_auth.h
342342
toxcore/tox_api.c
343343
toxcore/tox.c
344+
toxcore/tox.h
344345
toxcore/tox_dispatch.c
345346
toxcore/tox_dispatch.h
346347
toxcore/tox_event.c
347348
toxcore/tox_event.h
348349
toxcore/tox_events.c
349350
toxcore/tox_events.h
350-
toxcore/tox.h
351+
toxcore/tox_log_level.c
352+
toxcore/tox_log_level.h
351353
toxcore/tox_options.c
352354
toxcore/tox_options.h
353355
toxcore/tox_private.c
@@ -371,6 +373,7 @@ endif()
371373
set(toxcore_PKGCONFIG_REQUIRES ${toxcore_PKGCONFIG_REQUIRES} libsodium)
372374
set(toxcore_API_HEADERS
373375
${toxcore_SOURCE_DIR}/toxcore/tox.h^tox
376+
${toxcore_SOURCE_DIR}/toxcore/tox_log_level.h^tox
374377
${toxcore_SOURCE_DIR}/toxcore/tox_options.h^tox)
375378
if(EXPERIMENTAL_API)
376379
set(toxcore_API_HEADERS ${toxcore_API_HEADERS}

other/docker/pkgsrc/pkgsrc.patch

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ diff --git a/chat/toxcore/PLIST b/chat/toxcore/PLIST
1414
index f0a5e4f04..4122b0867 100644
1515
--- a/chat/toxcore/PLIST
1616
+++ b/chat/toxcore/PLIST
17-
@@ -4,11 +4,10 @@ bin/tox-bootstrapd
17+
@@ -4,11 +4,11 @@ bin/tox-bootstrapd
1818
include/tox/tox.h
1919
-include/tox/tox_dispatch.h
2020
-include/tox/tox_events.h
21+
+include/tox/tox_log_level.h
2122
+include/tox/tox_options.h
2223
include/tox/toxav.h
2324
include/tox/toxencryptsave.h

toxcore/BUILD.bazel

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ exports_files(
66
"tox.h",
77
"tox_dispatch.h",
88
"tox_events.h",
9+
"tox_log_level.h",
910
"tox_options.h",
1011
"tox_private.h",
1112
],
@@ -1079,7 +1080,17 @@ cc_library(
10791080
hdrs = ["tox_options.h"],
10801081
copts = ["-UTOX_HIDE_DEPRECATED"],
10811082
visibility = ["//c-toxcore:__subpackages__"],
1082-
deps = [":ccompat"],
1083+
deps = [
1084+
":ccompat",
1085+
":tox_log_level",
1086+
],
1087+
)
1088+
1089+
cc_library(
1090+
name = "tox_log_level",
1091+
srcs = ["tox_log_level.c"],
1092+
hdrs = ["tox_log_level.h"],
1093+
visibility = ["//c-toxcore:__subpackages__"],
10831094
)
10841095

10851096
cc_library(
@@ -1114,6 +1125,7 @@ cc_library(
11141125
":network",
11151126
":onion_client",
11161127
":state",
1128+
":tox_log_level",
11171129
":tox_options",
11181130
":util",
11191131
"//c-toxcore/toxencryptsave:defines",
@@ -1128,6 +1140,7 @@ cc_test(
11281140
deps = [
11291141
":crypto_core",
11301142
":tox",
1143+
":tox_log_level",
11311144
":tox_options",
11321145
"@com_google_googletest//:gtest",
11331146
"@com_google_googletest//:gtest_main",

toxcore/Makefile.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ libtoxcore_la_SOURCES = ../third_party/cmp/cmp.c \
137137
../toxcore/tox_event.h \
138138
../toxcore/tox_events.c \
139139
../toxcore/tox_events.h \
140+
../toxcore/tox_log_level.c \
141+
../toxcore/tox_log_level.h \
140142
../toxcore/tox_options.c \
141143
../toxcore/tox_options.h \
142144
../toxcore/tox_pack.c \

toxcore/net_profile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* SPDX-License-Identifier: GPL-3.0-or-later
2-
* Copyright © 2023-2024 The TokTok team.
2+
* Copyright © 2023-2025 The TokTok team.
33
*/
44

55
/**

toxcore/net_profile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* SPDX-License-Identifier: GPL-3.0-or-later
2-
* Copyright © 2023-2024 The TokTok team.
2+
* Copyright © 2023-2025 The TokTok team.
33
*/
44

55
/**

toxcore/tox.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "network.h"
3333
#include "onion_client.h"
3434
#include "state.h"
35+
#include "tox_log_level.h"
3536
#include "tox_options.h"
3637
#include "tox_private.h"
3738
#include "tox_struct.h" // IWYU pragma: keep

toxcore/tox.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5361,7 +5361,6 @@ typedef Tox_User_Status TOX_USER_STATUS;
53615361
typedef Tox_Message_Type TOX_MESSAGE_TYPE;
53625362
typedef Tox_Proxy_Type TOX_PROXY_TYPE;
53635363
typedef Tox_Savedata_Type TOX_SAVEDATA_TYPE;
5364-
typedef Tox_Log_Level TOX_LOG_LEVEL;
53655364
typedef Tox_Connection TOX_CONNECTION;
53665365
typedef Tox_File_Control TOX_FILE_CONTROL;
53675366
typedef Tox_Conference_Type TOX_CONFERENCE_TYPE;

toxcore/tox_api.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -184,27 +184,6 @@ const char *tox_savedata_type_to_string(Tox_Savedata_Type value)
184184

185185
return "<invalid Tox_Savedata_Type>";
186186
}
187-
const char *tox_log_level_to_string(Tox_Log_Level value)
188-
{
189-
switch (value) {
190-
case TOX_LOG_LEVEL_TRACE:
191-
return "TOX_LOG_LEVEL_TRACE";
192-
193-
case TOX_LOG_LEVEL_DEBUG:
194-
return "TOX_LOG_LEVEL_DEBUG";
195-
196-
case TOX_LOG_LEVEL_INFO:
197-
return "TOX_LOG_LEVEL_INFO";
198-
199-
case TOX_LOG_LEVEL_WARNING:
200-
return "TOX_LOG_LEVEL_WARNING";
201-
202-
case TOX_LOG_LEVEL_ERROR:
203-
return "TOX_LOG_LEVEL_ERROR";
204-
}
205-
206-
return "<invalid Tox_Log_Level>";
207-
}
208187
const char *tox_err_options_new_to_string(Tox_Err_Options_New value)
209188
{
210189
switch (value) {

0 commit comments

Comments
 (0)