Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve android logging: Remove unnecessary print statements, and use Log.w where necessary #228

Merged
merged 4 commits into from Nov 22, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -3,6 +3,7 @@
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;

import java.util.Map;

Expand All @@ -26,6 +27,7 @@
*/
public class AblyEventStreamHandler implements EventChannel.StreamHandler {

private static final String TAG = AblyEventStreamHandler.class.getName();
/**
* Creating an ablyLibrary instance.
* As ablyLibrary is a singleton,
Expand Down Expand Up @@ -197,7 +199,7 @@ public void onListen(Object object, EventChannel.EventSink uiThreadEventSink) {
@Override
public void onCancel(Object object) {
if (object == null) {
System.out.println("Cannot process null input on cancel");
Log.w(TAG, "onCancel cannot decode null");
return;
}
final AblyFlutterMessage<AblyEventMessage<Object>> ablyMessage = getMessage(object);
Expand Down
Expand Up @@ -76,9 +76,7 @@ private void setupChannels(BinaryMessenger messenger, Context applicationContext
}

@Override
public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
System.out.println("Ably Plugin onDetachedFromEngine");
}
public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {}

private static MethodCodec createCodec(CipherParamsStorage cipherParamsStorage) {
return new StandardMethodCodec(new AblyMessageCodec(cipherParamsStorage));
Expand Down
@@ -1,5 +1,7 @@
package io.ably.flutter.plugin;

import android.util.Log;

import androidx.annotation.Nullable;

import com.google.firebase.messaging.RemoteMessage;
Expand Down Expand Up @@ -58,7 +60,7 @@ interface CodecDecoder<T> {
}

private static class CodecPair<T> {

private static final String TAG = CodecPair.class.getName();
final CodecEncoder<T> encoder;
final CodecDecoder<T> decoder;

Expand All @@ -69,15 +71,15 @@ private static class CodecPair<T> {

Map<String, Object> encode(final Object value) {
if (this.encoder == null) {
System.out.println("Codec encoder not defined");
Log.w(TAG, "Encoder is null");
return null;
}
return this.encoder.encode((T) value);
}

T decode(Map<String, Object> jsonMap) {
if (this.decoder == null) {
System.out.println("Codec decoder not defined");
Log.w(TAG, "Decoder is null");
return null;
}
return this.decoder.decode(jsonMap);
Expand Down
Expand Up @@ -151,7 +151,6 @@ private void handleAblyException(@NonNull MethodChannel.Result result, @NonNull
@Override
public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result rawResult) {
final MethodChannel.Result result = new MethodResultWrapper(rawResult);
System.out.println("Ably Plugin handle: " + call.method);
final BiConsumer<MethodCall, MethodChannel.Result> handler = _map.get(call.method);
if (null == handler) {
// We don't have a handler for a method with this name so tell the caller.
Expand All @@ -177,7 +176,6 @@ public void onError(ErrorInfo reason) {
}

private void register(@NonNull MethodCall call, @NonNull MethodChannel.Result result) {
System.out.println("Registering library instance to clean up any existing instances");
hotRestartCallback.on();
_ably.dispose();
result.success(null);
Expand Down Expand Up @@ -205,10 +203,7 @@ public void success(@Nullable Object result) {

@Override
public void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) {
System.out.println(errorDetails);
if (errorMessage != null) {
result.error("40000", String.format("Error from authCallback: %s", errorMessage), errorDetails);
}
result.error("40000", String.format("Error from authCallback: %s", errorMessage), errorDetails);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should've removed this change in this PR, because this result.error usage is removed completely in a future PR: https://github.com/ably/ably-flutter/pull/231/files because it causes a bug.

latch.countDown();
}

Expand Down