Skip to content

Commit

Permalink
refactor: rename PLog to log
Browse files Browse the repository at this point in the history
  • Loading branch information
wzieba committed Dec 13, 2023
1 parent 74ac580 commit 4f3f0e7
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.parsely.parselyandroid
import android.content.Context
import android.provider.Settings
import com.google.android.gms.ads.identifier.AdvertisingIdClient
import com.parsely.parselyandroid.Logging.PLog
import com.parsely.parselyandroid.Logging.log
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch

Expand All @@ -19,7 +19,7 @@ internal class AdvertisementIdProvider(
try {
adKey = AdvertisingIdClient.getAdvertisingIdInfo(context).id
} catch (e: Exception) {
PLog("No Google play services or error!")
log("No Google play services or error!")
}
}
}
Expand All @@ -41,7 +41,7 @@ internal class AndroidIdProvider(private val context: Context) : IdProvider {
} catch (ex: Exception) {
null
}
PLog(String.format("Android ID: %s", uuid))
log(String.format("Android ID: %s", uuid))
return uuid
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.parsely.parselyandroid

import android.os.Build
import com.parsely.parselyandroid.Logging.PLog
import com.parsely.parselyandroid.Logging.log

internal interface DeviceInfoRepository{
fun collectDeviceInfo(): Map<String, String>
Expand Down Expand Up @@ -35,12 +35,12 @@ internal open class AndroidDeviceInfoRepository(
val adKey = advertisementIdProvider.provide()
val androidId = androidIdProvider.provide()

PLog("adkey is: %s, uuid is %s", adKey, androidId)
log("adkey is: %s, uuid is %s", adKey, androidId)

return if (adKey != null) {
adKey
} else {
PLog("falling back to device uuid")
log("falling back to device uuid")
androidId .orEmpty()
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.parsely.parselyandroid

import com.parsely.parselyandroid.Logging.PLog
import kotlin.time.Duration
import com.parsely.parselyandroid.Logging.log
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
Expand Down Expand Up @@ -63,7 +62,7 @@ internal class EngagementManager(
val event: MutableMap<String, Any> = HashMap(
baseEvent
)
PLog(String.format("Enqueuing %s event.", event["action"]))
log(String.format("Enqueuing %s event.", event["action"]))

// Update `ts` for the event since it's happening right now.
val baseEventData = (event["data"] as Map<String, Any>?)!!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.parsely.parselyandroid;

import static com.parsely.parselyandroid.Logging.PLog;

import android.content.Context;
import static com.parsely.parselyandroid.Logging.log;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand Down Expand Up @@ -44,7 +42,7 @@ Map<String, Object> buildEvent(
Map<String, Object> extraData,
@Nullable String uuid
) {
PLog("buildEvent called for %s/%s", action, url);
log("buildEvent called for %s/%s", action, url);

Calendar now = Calendar.getInstance(TimeZone.getTimeZone("UTC"));

Expand Down
18 changes: 9 additions & 9 deletions parsely/src/main/java/com/parsely/parselyandroid/FlushQueue.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.parsely.parselyandroid

import com.parsely.parselyandroid.JsonSerializer.toParselyEventsPayload
import com.parsely.parselyandroid.Logging.PLog
import com.parsely.parselyandroid.Logging.log
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.sync.Mutex
Expand All @@ -19,7 +19,7 @@ internal class FlushQueue(

operator fun invoke(skipSendingEvents: Boolean) {
if (!connectivityStatusProvider.isReachable()) {
PLog("Network unreachable. Not flushing.")
log("Network unreachable. Not flushing.")
return
}
scope.launch {
Expand All @@ -32,23 +32,23 @@ internal class FlushQueue(
}

if (skipSendingEvents) {
PLog("Debug mode on. Not sending to Parse.ly. Otherwise, would sent ${eventsToSend.size} events")
log("Debug mode on. Not sending to Parse.ly. Otherwise, would sent ${eventsToSend.size} events")
repository.remove(eventsToSend)
return@launch
}
PLog("Sending request with %d events", eventsToSend.size)
log("Sending request with %d events", eventsToSend.size)
val jsonPayload = toParselyEventsPayload(eventsToSend)
PLog("POST Data %s", jsonPayload)
PLog("Requested %s", ParselyTracker.ROOT_URL)
log("POST Data %s", jsonPayload)
log("Requested %s", ParselyTracker.ROOT_URL)
restClient.send(jsonPayload)
.fold(
onSuccess = {
PLog("Pixel request success")
log("Pixel request success")
repository.remove(eventsToSend)
},
onFailure = {
PLog("Pixel request exception")
PLog(it.toString())
log("Pixel request exception")
log(it.toString())
}
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.parsely.parselyandroid

import com.parsely.parselyandroid.Logging.PLog
import com.parsely.parselyandroid.Logging.log
import kotlin.time.Duration.Companion.seconds
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.delay
Expand All @@ -23,7 +23,7 @@ internal class InMemoryBuffer(
while (isActive) {
mutex.withLock {
if (buffer.isNotEmpty()) {
PLog("Persisting ${buffer.size} events")
log("Persisting ${buffer.size} events")
localStorageRepository.insertEvents(buffer)
buffer.clear()
}
Expand All @@ -36,7 +36,7 @@ internal class InMemoryBuffer(
fun add(event: Map<String, Any>) {
coroutineScope.launch {
mutex.withLock {
PLog("Event added to buffer")
log("Event added to buffer")
buffer.add(event)
onEventAddedListener()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.parsely.parselyandroid

import android.content.Context
import com.parsely.parselyandroid.Logging.PLog
import com.parsely.parselyandroid.Logging.log
import java.io.EOFException
import java.io.FileNotFoundException
import java.io.ObjectInputStream
Expand Down Expand Up @@ -35,7 +35,7 @@ internal class LocalStorageRepository(private val context: Context) : QueueRepos
oos.close()
fos.close()
} catch (ex: Exception) {
PLog("Exception thrown during queue serialization: %s", ex.toString())
log("Exception thrown during queue serialization: %s", ex.toString())
}
}

Expand All @@ -53,7 +53,7 @@ internal class LocalStorageRepository(private val context: Context) : QueueRepos
} catch (ex: FileNotFoundException) {
// Nothing to do here. Means there was no saved queue.
} catch (ex: Exception) {
PLog(
log(
"Exception thrown during queue deserialization: %s",
ex.toString()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ object Logging {
* Log a message to the console.
*/
@JvmStatic
fun PLog(logString: String, vararg objects: Any?) {
fun log(logString: String, vararg objects: Any?) {
if (logString == "") {
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.parsely.parselyandroid;

import static com.parsely.parselyandroid.Logging.PLog;
import static com.parsely.parselyandroid.Logging.log;

import android.content.Context;

Expand Down Expand Up @@ -83,7 +83,7 @@ public Unit invoke() {
inMemoryBuffer = new InMemoryBuffer(ParselyCoroutineScopeKt.getSdkScope(), localStorageRepository, () -> {
if (!flushTimerIsActive()) {
startFlushTimer();
PLog("Flush flushTimer set to %ds", (flushManager.getIntervalMillis() / 1000));
log("Flush flushTimer set to %ds", (flushManager.getIntervalMillis() / 1000));
}
return Unit.INSTANCE;
});
Expand Down Expand Up @@ -201,7 +201,7 @@ public long getFlushInterval() {
*/
public void setDebug(boolean debug) {
isDebug = debug;
PLog("Debugging is now set to " + isDebug);
log("Debugging is now set to " + isDebug);
}

/**
Expand Down

0 comments on commit 4f3f0e7

Please sign in to comment.