From d4f2216b3a7e2ecd08ad7750573b54773376510a Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Tue, 21 May 2024 17:26:17 +0200 Subject: [PATCH] chore: Rename `Logger.h` to `MmkvLogger.h` (#684) * chore: Rename `Logger.h` to `MmkvLogger.h` * Add check-all * Update package.json * chore: Build CI on iPhone 15 --- .github/workflows/build-ios.yml | 2 +- package/android/src/main/cpp/AndroidLogger.cpp | 6 +++--- package/cpp/MmkvHostObject.cpp | 8 ++++---- package/cpp/{Logger.h => MmkvLogger.h} | 6 +++--- package/cpp/NativeMmkvModule.cpp | 4 ++-- package/ios/AppleLogger.mm | 6 +++--- package/package.json | 1 + 7 files changed, 17 insertions(+), 16 deletions(-) rename package/cpp/{Logger.h => MmkvLogger.h} (94%) diff --git a/.github/workflows/build-ios.yml b/.github/workflows/build-ios.yml index 3d2e0e23..baf797f4 100644 --- a/.github/workflows/build-ios.yml +++ b/.github/workflows/build-ios.yml @@ -79,6 +79,6 @@ jobs: -scheme MmkvExample \ -sdk iphonesimulator \ -configuration Debug \ - -destination 'platform=iOS Simulator,name=iPhone 11 Pro' \ + -destination 'platform=iOS Simulator,name=iPhone 15' \ build \ CODE_SIGNING_ALLOWED=NO | xcpretty" diff --git a/package/android/src/main/cpp/AndroidLogger.cpp b/package/android/src/main/cpp/AndroidLogger.cpp index cd5d078b..bd953b00 100644 --- a/package/android/src/main/cpp/AndroidLogger.cpp +++ b/package/android/src/main/cpp/AndroidLogger.cpp @@ -1,14 +1,14 @@ // -// AndroidLogger.cpp +// AndroidMmkvLogger.cpp // react-native-mmkv // // Created by Marc Rousavy on 05.03.24. // -#include "Logger.h" +#include "MmkvLogger.h" #include -void Logger::log(const std::string& tag, const std::string& message) { +void MmkvLogger::log(const std::string& tag, const std::string& message) { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wformat-security" __android_log_print(ANDROID_LOG_INFO, tag.c_str(), message.c_str()); diff --git a/package/cpp/MmkvHostObject.cpp b/package/cpp/MmkvHostObject.cpp index dabda994..2d4b582b 100644 --- a/package/cpp/MmkvHostObject.cpp +++ b/package/cpp/MmkvHostObject.cpp @@ -7,8 +7,8 @@ // #include "MmkvHostObject.h" -#include "Logger.h" #include "MMKVManagedBuffer.h" +#include "MmkvLogger.h" #include #include #include @@ -20,8 +20,8 @@ MmkvHostObject::MmkvHostObject(const facebook::react::MMKVConfig& config) { std::string path = config.path.has_value() ? config.path.value() : ""; std::string encryptionKey = config.encryptionKey.has_value() ? config.encryptionKey.value() : ""; bool hasEncryptionKey = encryptionKey.size() > 0; - Logger::log("RNMMKV", "Creating MMKV instance \"%s\"... (Path: %s, Encrypted: %s)", - config.id.c_str(), path.c_str(), hasEncryptionKey ? "true" : "false"); + MmkvLogger::log("RNMMKV", "Creating MMKV instance \"%s\"... (Path: %s, Encrypted: %s)", + config.id.c_str(), path.c_str(), hasEncryptionKey ? "true" : "false"); std::string* pathPtr = path.size() > 0 ? &path : nullptr; std::string* encryptionKeyPtr = encryptionKey.size() > 0 ? &encryptionKey : nullptr; @@ -52,7 +52,7 @@ MmkvHostObject::MmkvHostObject(const facebook::react::MMKVConfig& config) { MmkvHostObject::~MmkvHostObject() { if (instance != nullptr) { std::string instanceId = instance->mmapID(); - Logger::log("RNMMKV", "Destroying MMKV instance \"%s\"...", instanceId.c_str()); + MmkvLogger::log("RNMMKV", "Destroying MMKV instance \"%s\"...", instanceId.c_str()); instance->sync(); instance->clearMemoryCache(); } diff --git a/package/cpp/Logger.h b/package/cpp/MmkvLogger.h similarity index 94% rename from package/cpp/Logger.h rename to package/cpp/MmkvLogger.h index 9ccc4df2..2a524bae 100644 --- a/package/cpp/Logger.h +++ b/package/cpp/MmkvLogger.h @@ -1,5 +1,5 @@ // -// Logger.h +// MmkvLogger.h // react-native-mmkv // // Created by Marc Rousavy on 25.03.24. @@ -7,9 +7,9 @@ #include -class Logger { +class MmkvLogger { private: - Logger() = delete; + MmkvLogger() = delete; private: template diff --git a/package/cpp/NativeMmkvModule.cpp b/package/cpp/NativeMmkvModule.cpp index 5cddd0aa..3d7f5850 100644 --- a/package/cpp/NativeMmkvModule.cpp +++ b/package/cpp/NativeMmkvModule.cpp @@ -6,9 +6,9 @@ // #include "NativeMmkvModule.h" -#include "Logger.h" #include "MMKV.h" #include "MmkvHostObject.h" +#include "MmkvLogger.h" namespace facebook::react { @@ -20,7 +20,7 @@ bool NativeMmkvModule::initialize(jsi::Runtime& runtime, std::string basePath) { throw jsi::JSError(runtime, "Path cannot be empty!"); } - Logger::log("RNMMKV", "Initializing MMKV at %s...", basePath.c_str()); + MmkvLogger::log("RNMMKV", "Initializing MMKV at %s...", basePath.c_str()); #ifdef DEBUG MMKVLogLevel logLevel = MMKVLogDebug; diff --git a/package/ios/AppleLogger.mm b/package/ios/AppleLogger.mm index fa6ec24b..80aee610 100644 --- a/package/ios/AppleLogger.mm +++ b/package/ios/AppleLogger.mm @@ -1,14 +1,14 @@ // -// AppleLogger.m +// AppleMmkvLogger.m // react-native-mmkv // // Created by Marc Rousavy on 25.03.24. // -#import "Logger.h" +#import "MmkvLogger.h" #import -void Logger::log(const std::string& tag, const std::string& message) { +void MmkvLogger::log(const std::string& tag, const std::string& message) { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wformat-security" NSLog(@"[%s]: %s", tag.c_str(), message.c_str()); diff --git a/package/package.json b/package/package.json index 31866a68..36066f75 100644 --- a/package/package.json +++ b/package/package.json @@ -35,6 +35,7 @@ "lint": "eslint \"**/*.{js,ts,tsx}\"", "lint-ci": "yarn lint -f ./node_modules/@firmnav/eslint-github-actions-formatter/dist/formatter.js", "lint-cpp": "scripts/clang-format.sh", + "check-all": "yarn lint --fix && yarn lint-cpp", "test": "jest", "typecheck": "tsc --noEmit", "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",