Skip to content

Commit

Permalink
chore: Rename Logger.h to MmkvLogger.h (#684)
Browse files Browse the repository at this point in the history
* chore: Rename `Logger.h` to `MmkvLogger.h`

* Add check-all

* Update package.json

* chore: Build CI on iPhone 15
  • Loading branch information
mrousavy authored May 21, 2024
1 parent 7b95d56 commit d4f2216
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
6 changes: 3 additions & 3 deletions package/android/src/main/cpp/AndroidLogger.cpp
Original file line number Diff line number Diff line change
@@ -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 <android/log.h>

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());
Expand Down
8 changes: 4 additions & 4 deletions package/cpp/MmkvHostObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
//

#include "MmkvHostObject.h"
#include "Logger.h"
#include "MMKVManagedBuffer.h"
#include "MmkvLogger.h"
#include <MMKV.h>
#include <string>
#include <vector>
Expand All @@ -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;
Expand Down Expand Up @@ -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();
}
Expand Down
6 changes: 3 additions & 3 deletions package/cpp/Logger.h → package/cpp/MmkvLogger.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
//
// Logger.h
// MmkvLogger.h
// react-native-mmkv
//
// Created by Marc Rousavy on 25.03.24.
//

#include <string>

class Logger {
class MmkvLogger {
private:
Logger() = delete;
MmkvLogger() = delete;

private:
template <typename... Args>
Expand Down
4 changes: 2 additions & 2 deletions package/cpp/NativeMmkvModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
//

#include "NativeMmkvModule.h"
#include "Logger.h"
#include "MMKV.h"
#include "MmkvHostObject.h"
#include "MmkvLogger.h"

namespace facebook::react {

Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions package/ios/AppleLogger.mm
Original file line number Diff line number Diff line change
@@ -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 <Foundation/Foundation.h>

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());
Expand Down
1 change: 1 addition & 0 deletions package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit d4f2216

Please sign in to comment.