Skip to content

Commit 6d4d23d

Browse files
committed
cleanup: More cleanup of unused debug logging code.
1 parent 134bbee commit 6d4d23d

File tree

9 files changed

+19
-276
lines changed

9 files changed

+19
-276
lines changed

lib/src/jvmMain/cpp/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,6 @@ add_library(
121121
util/exceptions.cpp
122122
util/exceptions.h
123123
util/instance_manager.h
124-
util/logging.cpp
125-
util/logging.h
126124
util/pp_attributes.h
127125
util/pp_cat.h
128126
util/to_bytes.cpp

lib/src/jvmMain/cpp/ToxAv/av.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,7 @@ TOX_METHOD (jbyteArray, Iterate,
2525
return instances.with_instance (env, instanceNumber,
2626
[=] (ToxAV *av, Events &events) -> jbyteArray
2727
{
28-
InstanceLogEntry log_entry (instanceNumber, toxav_iterate, av);
29-
30-
#if 0
31-
log_entry.print_result (toxav_iterate, av, &events);
32-
#else
33-
log_entry.print_result (toxav_iterate, av);
34-
#endif
28+
toxav_iterate(av);
3529
if (events.ByteSizeLong () == 0)
3630
return nullptr;
3731

lib/src/jvmMain/cpp/ToxCore/connection.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,7 @@ TOX_METHOD (jbyteArray, Iterate,
103103
return instances.with_instance (env, instanceNumber,
104104
[=] (Tox *tox, Events &events) -> jbyteArray
105105
{
106-
InstanceLogEntry log_entry (instanceNumber, tox_iterate, tox);
107-
108-
log_entry.print_result (tox_iterate, tox, &events);
106+
tox_iterate(tox, &events);
109107
if (events.ByteSizeLong () == 0)
110108
return nullptr;
111109

lib/src/jvmMain/cpp/ToxCrypto/encryptsave.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCryptoJni_toxGetSalt
4949
auto data = fromJavaArray (env, dataArray);
5050
uint8_t salt[TOX_PASS_SALT_LENGTH] = { 0 };
5151

52-
LogEntry log_entry (tox_get_salt);
53-
return with_error_handling<ToxCrypto> (log_entry, env,
52+
return with_error_handling<ToxCrypto> (env,
5453
[env, &salt] (bool er)
5554
{
5655
return toJavaArray (env, salt);
@@ -93,8 +92,7 @@ JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCryptoJni_toxPassKeyD
9392
return nullptr;
9493
}
9594

96-
LogEntry log_entry (tox_pass_key_derive_with_salt);
97-
return with_error_handling<ToxCrypto> (log_entry, env,
95+
return with_error_handling<ToxCrypto> (env,
9896
[env] (Tox_Pass_Key *out_key)
9997
{
10098
pass_key_ptr deleter (out_key);
@@ -117,8 +115,7 @@ JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCryptoJni_toxPassKeyD
117115
{
118116
auto passphrase = fromJavaArray (env, passphraseArray);
119117

120-
LogEntry log_entry (tox_pass_key_derive);
121-
return with_error_handling<ToxCrypto> (log_entry, env,
118+
return with_error_handling<ToxCrypto> (env,
122119
[env] (Tox_Pass_Key *out_key)
123120
{
124121
pass_key_ptr deleter (out_key);
@@ -150,8 +147,7 @@ JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCryptoJni_toxPassKeyD
150147

151148
pass_key_ptr pass_key = pass_key_from_java (env, passKeyArray);
152149

153-
LogEntry log_entry (tox_pass_key_decrypt);
154-
return with_error_handling<ToxCrypto> (log_entry, env,
150+
return with_error_handling<ToxCrypto> (env,
155151
[env, &out] (bool)
156152
{
157153
return toJavaArray (env, out);
@@ -177,8 +173,7 @@ JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCryptoJni_toxPassKeyE
177173

178174
pass_key_ptr pass_key = pass_key_from_java (env, passKeyArray);
179175

180-
LogEntry log_entry (tox_pass_key_encrypt);
181-
return with_error_handling<ToxCrypto> (log_entry, env,
176+
return with_error_handling<ToxCrypto> (env,
182177
[env, &out] (bool)
183178
{
184179
return toJavaArray (env, out);

lib/src/jvmMain/cpp/tox/common.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#pragma once
22

3-
#include "util/debug_log.h"
4-
53
#include <cassert>
64
#include <memory>
75

@@ -25,10 +23,7 @@ namespace tox
2523
invoke (Subsystem *tox, Args ...args, void *user_data)
2624
{
2725
assert (tox != nullptr);
28-
LogEntry log_entry (Callback, args...);
29-
return log_entry.print_result (
30-
Callback, args..., static_cast<UserData *> (user_data)
31-
).unwrap ();
26+
return Callback(args..., static_cast<UserData *> (user_data));
3227
}
3328

3429
template<typename UserData, type<UserData> Callback>

lib/src/jvmMain/cpp/tox4j/ToxInstances.h

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#pragma once
22

3+
#include <iostream>
4+
35
#include "util/instance_manager.h"
6+
#include "util/jni/ArrayFromJava.h"
47
#include "util/pp_cat.h"
5-
#include "util/debug_log.h"
6-
7-
#include <iostream>
8+
#include "util/wrap_void.h"
89

910

1011

@@ -55,9 +56,9 @@ struct conversions
5556
}
5657

5758
static auto
58-
to_java (JNIEnv *env, LogEntry &log_entry, ToxFunc func, Args ...args)
59+
to_java (JNIEnv *env, ToxFunc func, Args ...args)
5960
{
60-
return to_java (env, log_entry.print_result (func, from_java (args)...));
61+
return to_java (env, wrap_void (func, from_java (args)...));
6162
}
6263
};
6364

@@ -228,12 +229,9 @@ throw_tox_exception (JNIEnv *env, ErrorType error)
228229
* The return type of with_error_handling is the result type of calling
229230
* success_func with the return value of tox_func called with args.
230231
*
231-
* It stores the result of the function call in the passed LogEntry.
232-
*
233232
* @param Object Tox or ToxAV, the type of the first parameter to the tox
234233
* function without pointer.
235234
*
236-
* @param log_entry A LogEntry to store the function result in.
237235
* @param env The current JNIEnv.
238236
* @param success_func Function to be called when the error code is OK.
239237
* @param tox_func The native function to call. Must have an error code as
@@ -243,8 +241,7 @@ throw_tox_exception (JNIEnv *env, ErrorType error)
243241
*/
244242
template<typename Object, typename SuccessFunc, typename ToxFunc, typename ...Args>
245243
auto
246-
with_error_handling (LogEntry &log_entry,
247-
JNIEnv *env,
244+
with_error_handling (JNIEnv *env,
248245
SuccessFunc success_func,
249246
ToxFunc tox_func,
250247
Args &&...args)
@@ -254,7 +251,7 @@ with_error_handling (LogEntry &log_entry,
254251
// Create an error code value and pass a pointer to the tox function.
255252
error_type error;
256253
auto value = conversions<ToxFunc, Args..., error_type *>::to_java (
257-
env, log_entry, tox_func, std::forward<Args> (args)..., &error
254+
env, tox_func, std::forward<Args> (args)..., &error
258255
);
259256
// Handle it, producing either a SUCCESS or a FAILURE with the error code.
260257
ErrorHandling result = handle_error_enum<error_type> (error);
@@ -283,8 +280,6 @@ with_error_handling (LogEntry &log_entry,
283280
* A Tox instance manager. In addition to the facilities provided by
284281
* instance_manager, this provides with_error_handling member functions for
285282
* tox error code to exception translation.
286-
*
287-
* All function calls are logged to a LogEntry.
288283
*/
289284
template<typename ObjectP, typename EventsP>
290285
struct ToxInstances
@@ -307,9 +302,8 @@ struct ToxInstances
307302
ToxFunc tox_func,
308303
Args &&...args)
309304
{
310-
LogEntry log_entry (tox_func, args...);
311305
return ::with_error_handling<Object> (
312-
log_entry, env, success_func,
306+
env, success_func,
313307
tox_func, std::forward<Args> (args)...
314308
);
315309
}
@@ -330,9 +324,8 @@ struct ToxInstances
330324
[&] (Object *tox, Events &events)
331325
{
332326
unused (events);
333-
InstanceLogEntry log_entry (instanceNumber, tox_func, tox, args...);
334327
return ::with_error_handling<Object> (
335-
log_entry, env, success_func,
328+
env, success_func,
336329
tox_func, tox, std::forward<Args> (args)...
337330
);
338331
}
@@ -376,9 +369,8 @@ struct ToxInstances
376369
[&] (Object *tox, Events &events)
377370
{
378371
unused (events);
379-
InstanceLogEntry log_entry (instanceNumber, tox_func, tox, args...);
380372
return conversions<ToxFunc, Object *, Args...>::to_java (
381-
env, log_entry, tox_func, tox, std::forward<Args> (args)...
373+
env, tox_func, tox, std::forward<Args> (args)...
382374
);
383375
}
384376
);

lib/src/jvmMain/cpp/util/debug_log.h

Lines changed: 0 additions & 130 deletions
This file was deleted.

lib/src/jvmMain/cpp/util/logging.cpp

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)