@@ -250,7 +250,7 @@ public void pinnedCertificates(ReadableArray args){
250250 }
251251 }
252252 }
253- log ("Certificate failed." );
253+ log ("Certificate failed." , LogLevel . INFO );
254254 return new String []{};
255255 }
256256
@@ -455,7 +455,7 @@ public void pushTokenType(ReadableArray args) {
455455 int messagingMode = Integer .parseInt (args .getString (0 ));
456456 this .channelName = args .getString (1 );
457457 this .channelDescription = args .getString (2 );
458- log ("pushTokenType [" + messagingMode + "][" + this .channelName + "][" + this .channelDescription + "]" );
458+ log ("pushTokenType [" + messagingMode + "][" + this .channelName + "][" + this .channelDescription + "]" , LogLevel . INFO );
459459
460460 if (messagingMode == 0 ) {
461461 this .messagingMode = Countly .CountlyMessagingMode .PRODUCTION ;
@@ -468,15 +468,15 @@ public void pushTokenType(ReadableArray args) {
468468 public static void onNotification (Map <String , String > notification ){
469469 JSONObject json = new JSONObject (notification );
470470 String notificationString = json .toString ();
471- log ("onNotification [" + notificationString + "]" );
471+ log ("onNotification [" + notificationString + "]" , LogLevel . INFO );
472472
473473 if (notificationListener != null ){
474474 //there is a listener for notifications, send the just received notification to it
475- log ("onNotification, listener exists" );
475+ log ("onNotification, listener exists" , LogLevel . INFO );
476476 notificationListener .callback (notificationString );
477477 }else {
478478 //there is no listener for notifications. Store this notification for when a listener is created
479- log ("onNotification, listener does not exist" );
479+ log ("onNotification, listener does not exist" , LogLevel . INFO );
480480 lastStoredNotification = notificationString ;
481481 }
482482 }
@@ -495,7 +495,7 @@ public void callback(String result) {
495495 .emit ("onCountlyPushNotification" , result );
496496 }
497497 };
498- log ("registerForNotification theCallback" );
498+ log ("registerForNotification theCallback" , LogLevel . INFO );
499499 if (lastStoredNotification != null ){
500500 notificationListener .callback (lastStoredNotification );
501501 lastStoredNotification = null ;
@@ -866,50 +866,30 @@ public void enableAttribution(){
866866 }
867867
868868 enum LogLevel {INFO , DEBUG , VERBOSE , WARNING , ERROR }
869- static void log (String message ) {
870- log (message , LogLevel .INFO );
871- }
872869 static void log (String message , LogLevel logLevel ) {
873- if (loggingEnabled ) {
874- switch (logLevel ) {
875- case INFO :
876- Log .i (TAG , message );
877- break ;
878- case DEBUG :
879- Log .d (TAG , message );
880- break ;
881- case WARNING :
882- Log .w (TAG , message );
883- break ;
884- case ERROR :
885- Log .e (TAG , message );
886- break ;
887- case VERBOSE :
888- Log .v (TAG , message );
889- break ;
890- }
891- }
870+ log (message , null , logLevel );
892871 }
893872
894873 static void log (String message , Throwable tr , LogLevel logLevel ) {
895- if (loggingEnabled ) {
896- switch (logLevel ) {
897- case INFO :
898- Log .i (TAG , message , tr );
899- break ;
900- case DEBUG :
901- Log .d (TAG , message , tr );
902- break ;
903- case WARNING :
904- Log .w (TAG , message , tr );
905- break ;
906- case ERROR :
907- Log .e (TAG , message , tr );
908- break ;
909- case VERBOSE :
910- Log .v (TAG , message , tr );
911- break ;
912- }
874+ if (!loggingEnabled ) {
875+ return ;
876+ }
877+ switch (logLevel ) {
878+ case INFO :
879+ Log .i (TAG , message , tr );
880+ break ;
881+ case DEBUG :
882+ Log .d (TAG , message , tr );
883+ break ;
884+ case WARNING :
885+ Log .w (TAG , message , tr );
886+ break ;
887+ case ERROR :
888+ Log .e (TAG , message , tr );
889+ break ;
890+ case VERBOSE :
891+ Log .v (TAG , message , tr );
892+ break ;
913893 }
914894 }
915895
0 commit comments