Skip to content

Commit

Permalink
Rename log macros
Browse files Browse the repository at this point in the history
  • Loading branch information
CedNaru committed Sep 18, 2024
1 parent a955b0e commit a11df23
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 63 deletions.
6 changes: 3 additions & 3 deletions src/editor/godot_kotlin_jvm_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void GodotKotlinJvmEditor::on_file_system_dock_file_moved(// NOLINT(readability-
const String& new_file
) {
if (file.ends_with(String(".") + GODOT_JVM_REGISTRATION_FILE_EXTENSION)) {
JVM_WARNING(
JVM_LOG_WARNING(
"You should not move registration files in the godot editor! Use the IDE for that. File moved: %s -> %s", file, new_file
);
}
Expand All @@ -26,7 +26,7 @@ void GodotKotlinJvmEditor::on_file_system_dock_file_removed(// NOLINT(readabilit
const String& file
) {
if (file.ends_with(String(".") + GODOT_JVM_REGISTRATION_FILE_EXTENSION)) {
JVM_WARNING("You should not remove registration files in the godot editor! Use the IDE for that. File removed: %s", file);
JVM_LOG_WARNING("You should not remove registration files in the godot editor! Use the IDE for that. File removed: %s", file);
}
}

Expand All @@ -38,7 +38,7 @@ void GodotKotlinJvmEditor::on_file_system_dock_folder_moved(// NOLINT(readabilit
String file_path = dir_access->get_next();
while (!file_path.is_empty()) {
if (file_path.ends_with(String(".") + GODOT_JVM_REGISTRATION_FILE_EXTENSION)) {
JVM_WARNING("You should not move folders with registration files in the godot editor! Use the IDE for that. Folder moved: %s", folder);
JVM_LOG_WARNING("You should not move folders with registration files in the godot editor! Use the IDE for that. Folder moved: %s", folder);
break;
}
file_path = dir_access->get_next();
Expand Down
22 changes: 11 additions & 11 deletions src/gd_kotlin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ void GDKotlin::fetch_user_configuration() {

// The function is going to mutate the provided configuration with the valid values found in the file.
// If some of the values parsed in the file are invalid, it will return true;
JVM_VERBOSE("Parsing JSON configuration file...");
JVM_LOG_VERBOSE("Parsing JSON configuration file...");
invalid_file_content = JvmUserConfiguration::parse_configuration_json(content, user_configuration);
if (invalid_file_content) {
JVM_WARNING("Configuration file is malformed. One or several settings might not be applied.");
JVM_LOG_WARNING("Configuration file is malformed. One or several settings might not be applied.");
}
} else {
// No need for a warning, it's most likely the first time the project is run.
JVM_LOG("No JVM user_configuration file found. Default settings for your platform will be used.");
JVM_LOG_INFO("No JVM user_configuration file found. Default settings for your platform will be used.");
}

#ifdef TOOLS_ENABLED
Expand All @@ -52,15 +52,15 @@ void GDKotlin::fetch_user_configuration() {
if (invalid_file_content || !configuration_file_exist) {
Ref<FileAccess> file_access = FileAccess::open(JVM_CONFIGURATION_PATH, FileAccess::WRITE);
String json = JvmUserConfiguration::export_configuration_to_json(user_configuration);
JVM_LOG("Writing a new configuration file to disk at %s", JVM_CONFIGURATION_PATH);
JVM_LOG_INFO("Writing a new configuration file to disk at %s", JVM_CONFIGURATION_PATH);
file_access->store_string(json);
}
#endif

HashMap<String, Variant> cmd_argument_map;
JVM_VERBOSE("Parsing commandline arguments...");
JVM_LOG_VERBOSE("Parsing commandline arguments...");
JvmUserConfiguration::parse_command_line(OS::get_singleton()->get_cmdline_args(), cmd_argument_map);
JVM_VERBOSE("Creating final JVM Configuration...");
JVM_LOG_VERBOSE("Creating final JVM Configuration...");
JvmUserConfiguration::merge_with_command_line(user_configuration, cmd_argument_map);
JvmUserConfiguration::sanitize_and_log_configuration(user_configuration);
}
Expand All @@ -83,7 +83,7 @@ void GDKotlin::set_jvm_options() {
if (user_configuration.jvm_jmx_port >= 0) { jvm_options.add_jmx_option(user_configuration.jvm_jmx_port); }

if (!Engine::get_singleton()->is_editor_hint() && !user_configuration.jvm_args.is_empty()) {
JVM_WARNING("You are using custom arguments for the JVM. Make sure they are valid or you risk the JVM to not "
JVM_LOG_WARNING("You are using custom arguments for the JVM. Make sure they are valid or you risk the JVM to not "
"launch properly");
jvm_options.add_custom_options(user_configuration.jvm_args);
}
Expand All @@ -103,7 +103,7 @@ String GDKotlin::copy_new_file_to_user_dir(const String& file_name) {

#ifndef __ANDROID__
if (!FileAccess::exists(file_user_path) || FileAccess::get_md5(file_user_path) != FileAccess::get_md5(file_res_path)) {
JVM_VERBOSE("%s file has changed. Copying it from res:// to user://.", file_name);
JVM_LOG_VERBOSE("%s file has changed. Copying it from res:// to user://.", file_name);
#else
// as per suggestion of https://developer.android.com/about/versions/14/behavior-changes-14#safer-dynamic-code-loading, we first delete existing files and then copy them again
// if we don't do this, subsequent app starts where the files already exist, error out
Expand Down Expand Up @@ -144,7 +144,7 @@ bool GDKotlin::load_bootstrap() {
#endif

JVM_ERR_FAIL_COND_V_MSG(!FileAccess::exists(bootstrap_jar), false, error_text);
JVM_VERBOSE("Loading bootstrap jar: %s", bootstrap_jar);
JVM_LOG_VERBOSE("Loading bootstrap jar: %s", bootstrap_jar);

bootstrap_class_loader = ClassLoader::create_instance(env, bootstrap_jar, jni::JObject(nullptr));
bootstrap_class_loader->set_as_context_loader(env);
Expand Down Expand Up @@ -181,7 +181,7 @@ bool GDKotlin::load_user_code() {
#else
String user_code_path {copy_new_file_to_user_dir(USER_CODE_FILE)};
#endif
JVM_VERBOSE("Loading usercode file at: %s", user_code_path);
JVM_LOG_VERBOSE("Loading usercode file at: %s", user_code_path);
// TODO: Rework this part when cpp reloading done, can't check what's happening in the Kotlin code from here.
ClassLoader* user_class_loader = ClassLoader::create_instance(
env,
Expand Down Expand Up @@ -264,7 +264,7 @@ bool GDKotlin::load_dynamic_lib() {
#ifdef TOOLS_ENABLED
else if (String environment_jvm = get_path_to_environment_jvm();
!environment_jvm.is_empty() && FileAccess::exists(environment_jvm)) {
JVM_WARNING("Godot-JVM: You really should embed a JRE in your project with jlink! See the "
JVM_LOG_WARNING("Godot-JVM: You really should embed a JRE in your project with jlink! See the "
"documentation if you don't know how to do that");
path_to_jvm_lib = environment_jvm;
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/jvm_wrapper/bootstrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void Bootstrap::load_classes(JNIEnv* p_env, jobject p_this, jobjectArray p_class

void Bootstrap::register_engine_type(JNIEnv* p_env, jobject p_this, jobjectArray p_classes_names, jobjectArray p_singleton_names) {
#ifdef DEV_ENABLED
JVM_VERBOSE("Starting to register managed engine types...");
JVM_LOG_VERBOSE("Starting to register managed engine types...");
#endif
jni::Env env(p_env);

Expand All @@ -39,7 +39,7 @@ void Bootstrap::register_engine_type(JNIEnv* p_env, jobject p_this, jobjectArray
engine_types.delete_local_ref(env);
singleton_names.delete_local_ref(env);
#ifdef DEV_ENABLED
JVM_VERBOSE("Done registering managed engine types...");
JVM_LOG_VERBOSE("Done registering managed engine types...");
#endif
}

Expand Down
4 changes: 2 additions & 2 deletions src/jvm_wrapper/memory/memory_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ void MemoryManager::sync_memory(jni::Env& p_env) {
}

void MemoryManager::clean_up(jni::Env& p_env) {
JVM_VERBOSE("Cleaning JVM Memory...");
JVM_LOG_VERBOSE("Cleaning JVM Memory...");
wrapped.call_void_method(p_env, CLEAN_UP);
JVM_VERBOSE("JVM Memory cleaned!");
JVM_LOG_VERBOSE("JVM Memory cleaned!");
}

void MemoryManager::queue_dead_object(Object* obj) {
Expand Down
2 changes: 1 addition & 1 deletion src/jvm_wrapper/memory/type_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void TypeManager::register_engine_types(jni::Env& p_env, jni::JObjectArray& p_en
engine_type_names.insert(i, class_name);
java_engine_types_constructors[class_name] = i;
#ifdef DEV_ENABLED
JVM_VERBOSE("Registered %s engine type with index %s.", class_name, i);
JVM_LOG_VERBOSE("Registered %s engine type with index %s.", class_name, i);
#endif
type.delete_local_ref(p_env);
}
Expand Down
6 changes: 3 additions & 3 deletions src/kotlin_editor_export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static constexpr const char* all_jvm_feature {"export-all-jvm"};
static constexpr const char* ios_jdk_version {"21"};

void KotlinEditorExportPlugin::_export_begin(const HashSet<String>& p_features, bool p_debug, const String& p_path, int p_flags) {
JVM_LOG("Beginning Godot-Jvm specific exports.");
JVM_LOG_INFO("Beginning Godot-Jvm specific exports.");

// Add mandatory jars to pck
Vector<String> files_to_add;
Expand Down Expand Up @@ -156,10 +156,10 @@ void KotlinEditorExportPlugin::_export_begin(const HashSet<String>& p_features,
JVM_ERR_FAIL_MSG("File can't be found, it won't be exported: %s", file_to_add);
}
add_file(file_to_add, FileAccess::get_file_as_bytes(file_to_add), false);
JVM_LOG("Exporting %s", file_to_add);
JVM_LOG_INFO("Exporting %s", file_to_add);
}

JVM_LOG("Finished Godot-Jvm specific exports.");
JVM_LOG_INFO("Finished Godot-Jvm specific exports.");
}

void KotlinEditorExportPlugin::_generate_export_configuration_file(jni::JvmType vm_type) {
Expand Down
6 changes: 3 additions & 3 deletions src/lifecycle/jvm_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ bool JvmManager::initialize_or_get_jvm(void* lib_handle, JvmUserConfiguration& u

std::locale global;

JVM_VERBOSE("Starting JVM ...");
JVM_LOG_VERBOSE("Starting JVM ...");
JNIEnv* jni_env {nullptr};

CreateJavaVM func {get_create_jvm_function(lib_handle)};
Expand All @@ -84,7 +84,7 @@ bool JvmManager::initialize_or_get_jvm(void* lib_handle, JvmUserConfiguration& u
JVM_ERR_FAIL_COND_V_MSG(result != JNI_OK, false, "Failed to create a new vm!");

#elif defined PROVIDED_JVM
JVM_VERBOSE("Retrieving existing JVM ...");
JVM_LOG_VERBOSE("Retrieving existing JVM ...");
jni::Env env {get_jni_env()};
java_vm = env.get_jvm();
#else
Expand Down Expand Up @@ -168,7 +168,7 @@ void JvmManager::destroy_jni_classes() {

void JvmManager::close_jvm() {
#if defined DYNAMIC_JVM || defined STATIC_JVM
JVM_VERBOSE("Shutting down JVM ...");
JVM_LOG_VERBOSE("Shutting down JVM ...");
jni::Jvm::destroy();
#endif
}
2 changes: 1 addition & 1 deletion src/lifecycle/jvm_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void JvmOptions::add_jmx_option(uint16_t p_port) {
options.push_back("-Dcom.sun.management.jmxremote.local.only=false");
options.push_back("-Dcom.sun.management.jmxremote.authenticate=false");
options.push_back("-Dcom.sun.management.jmxremote.ssl=false");
JVM_VERBOSE("Started JMX on port: %s", jvm_jmx_port);
JVM_LOG_VERBOSE("Started JMX on port: %s", jvm_jmx_port);
}

void JvmOptions::add_custom_options(const String& custom_options) {
Expand Down
Loading

0 comments on commit a11df23

Please sign in to comment.