fix: Log in FrameProcessorPluginRegistry (#2012)

* fix: Log when adding Frame Processor Plugin

* fix: Also log on Android

* Add logs in get as well

* fix: Fix string concat on Android
This commit is contained in:
Marc Rousavy 2023-10-16 17:51:18 +02:00 committed by GitHub
parent ce9a505776
commit 2af965d1ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View File

@ -1,5 +1,6 @@
package com.mrousavy.camera.frameprocessor;
import android.util.Log;
import androidx.annotation.Keep;
import androidx.annotation.Nullable;
import com.facebook.proguard.annotations.DoNotStrip;
@ -10,6 +11,7 @@ import java.util.HashMap;
@Keep
public class FrameProcessorPluginRegistry {
private static final Map<String, PluginInitializer> Plugins = new HashMap<>();
private static final String TAG = "FrameProcessorPluginRegistry";
@DoNotStrip
@Keep
@ -17,15 +19,19 @@ public class FrameProcessorPluginRegistry {
assert !Plugins.containsKey(name) : "Tried to add a Frame Processor Plugin with a name that already exists! " +
"Either choose unique names, or remove the unused plugin. Name: " + name;
Plugins.put(name, pluginInitializer);
Log.i(TAG, "Successfully registered Frame Processor Plugin \"" + name + "\"!");
}
@DoNotStrip
@Keep
public static FrameProcessorPlugin getPlugin(String name, Map<String, Object> options) {
Log.i(TAG, "Looking up Frame Processor Plugin \"" + name + "\"...");
PluginInitializer initializer = Plugins.get(name);
if (initializer == null) {
Log.i(TAG, "Frame Processor Plugin \"" + name + "\" does not exist!");
return null;
}
Log.i(TAG, "Frame Processor Plugin \"" + name + "\" found! Initializing...");
return initializer.initializePlugin(options);
}

View File

@ -28,14 +28,18 @@
name);
[[FrameProcessorPluginRegistry frameProcessorPlugins] setValue:pluginInitializer forKey:name];
NSLog(@"Successfully registered Frame Processor Plugin \"%@\"!", name);
}
+ (FrameProcessorPlugin*)getPlugin:(NSString* _Nonnull)name withOptions:(NSDictionary* _Nullable)options {
NSLog(@"Looking up Frame Processor Plugin \"%@\"...", name);
PluginInitializerFunction initializer = [[FrameProcessorPluginRegistry frameProcessorPlugins] objectForKey:name];
if (initializer == nil) {
NSLog(@"Frame Processor Plugin \"%@\" does not exist!", name);
return nil;
}
NSLog(@"Frame Processor Plugin \"%@\" found! Initializing...", name);
return initializer(options);
}