Skip to content

Commit

Permalink
Changing logging to UnityLogging and fixing things Jason pointed out.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathansligh-nimbus committed Sep 23, 2024
1 parent 4ac599b commit 52bc6a6
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 17 deletions.
6 changes: 3 additions & 3 deletions com.adsbynimbus.nimbus/Editor/IOSPostBuildProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ public static void OnPostprocessBuild(BuildTarget target, string path) {
private static void CopyPodfile(string pathToBuiltProject) {
var podfile = new IOSBuildDependencies();
var destPodfilePath = pathToBuiltProject + "/Podfile";
Debug.Log($"Copying generating pod file to {destPodfilePath}");
Debug.unityLogger.Log($"Copying generating pod file to {destPodfilePath}");
if (!File.Exists(destPodfilePath)) {
File.WriteAllText(destPodfilePath, podfile.BuildDependencies());
}
else {
Debug.Log("Podfile already exists");
Debug.unityLogger.Log("Podfile already exists");
}
}

Expand Down Expand Up @@ -110,7 +110,7 @@ private static void AddSkaAdNetworkIdsToPlist(string path) {
}
}

Debug.Log($"Writing SkAdNetwork ids to {path}");
Debug.unityLogger.Log($"Writing SkAdNetwork ids to {path}");
plist.WriteToFile(plistPath);
}
}
Expand Down
16 changes: 9 additions & 7 deletions com.adsbynimbus.nimbus/Editor/NimbusManagerCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,14 @@ private void OnGUI() {

_asset.Sanitize();
if (_asset.apiKey.IsNullOrEmpty()) {
Debug.LogError("Apikey cannot be empty, object NimbusAdsManager not created");
Debug.unityLogger.LogError("Nimbus",
"Apikey cannot be empty, object NimbusAdsManager not created");
return;
}

if (_asset.publisherKey.IsNullOrEmpty()) {
Debug.LogError("Publisher cannot be empty, object NimbusAdsManager not created");
Debug.unityLogger.LogError("Nimbus",
"Publisher cannot be empty, object NimbusAdsManager not created");
return;
}

Expand Down Expand Up @@ -241,7 +243,7 @@ private bool ValidateApsData() {
#endif

if (appId.IsNullOrEmpty()) {
Debug.LogError(
Debug.unityLogger.LogError("Nimbus",
"APS SDK has been included, the APS App ID cannot be empty, object NimbusAdsManager not created");
return false;
}
Expand All @@ -257,21 +259,21 @@ private bool ValidateApsData() {
#endif

if (slotData == null || slotData.Length == 0) {
Debug.LogError(
Debug.unityLogger.LogError("Nimbus",
$"APS SDK has been included, APS placement slots for {platform} need to be entered, object NimbusAdsManager not created");
return false;
}

var seenAdTypes = new Dictionary<AdUnitType, bool>();
foreach (var apsSlot in slotData) {
if (apsSlot.SlotId.IsNullOrEmpty()) {
Debug.LogError(
Debug.unityLogger.LogError("Nimbus",
$"APS SDK has been included, the APS slot id for {platform} cannot be empty, object NimbusAdsManager not created");
return false;
}

if (apsSlot.AdUnitType == AdUnitType.Undefined) {
Debug.LogError(
Debug.unityLogger.LogError("Nimbus",
$"APS SDK has been included, Ad Unit type for {platform} cannot be Undefined, object NimbusAdsManager not created");
return false;
}
Expand All @@ -280,7 +282,7 @@ private bool ValidateApsData() {
seenAdTypes.Add(apsSlot.AdUnitType, true);
}
else {
Debug.LogError(
Debug.unityLogger.LogError("Nimbus",
$"APS SDK has been included, APS cannot contain duplicate ad type {apsSlot.AdUnitType} for {platform}, object NimbusAdsManager not created");
return false;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID
#else
#if !UNITY_EDITOR && !UNITY_IOS && !UNITY_ANDROID
using System.Reflection;
using System.Runtime.InteropServices;

Expand Down
3 changes: 1 addition & 2 deletions com.adsbynimbus.nimbus/Runtime/Plugins/RTB.Tests/Tests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID
#else
#if !UNITY_EDITOR && !UNITY_IOS && !UNITY_ANDROID
using System;
using System.Diagnostics;
using Newtonsoft.Json;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Nimbus.ScriptableObjects;
using OpenRTB.Request;
using static System.String;
using UnityEngine;

#if !UNITY_EDITOR
using System.Text;
Expand Down Expand Up @@ -53,6 +54,7 @@ public async Task<string> MakeRequestAsync(BidRequest bidRequest) {
#else
// This will throw an exception if the bid request is missing required data from Nimbus
var body = JsonConvert.SerializeObject(bidRequest);
Debug.unityLogger.Log("Nimbus", "BID REQUEST: " + body);
HttpContent jsonBody = new StringContent(body, Encoding.UTF8, "application/json");
var serverResponse = await Client.PostAsync(_nimbusEndpoint, jsonBody, _ctx.Token);
if (_ctx.Token.IsCancellationRequested) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ await Task.Run(async () => {
_adEvents.FireOnAdErrorEvent(this);
return;
}
Debug.Log("BID RESPONSE: " + response);
Debug.unityLogger.Log("Nimbus","BID RESPONSE: " + response);
_adWasReturned = true;
RawBidResponse = response;
BidResponse = JsonConvert.DeserializeObject<BidResponse>(response);
Expand Down
3 changes: 1 addition & 2 deletions com.adsbynimbus.nimbus/Runtime/Scripts/NimbusManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public async void RequestRefreshingBannerAdAndLoad(CancellationTokenSource sourc
/// </param>
public void ShowLoadedAd(NimbusAdUnit adUnit) {
if (adUnit == null) {
Debug.unityLogger.LogError("",
Debug.unityLogger.LogError("Nimbus",
"there was no ad to render, likely there was no fill meaning that demand did not want to spend");
return;
}
Expand Down Expand Up @@ -486,7 +486,6 @@ private async Task<string> MakeRequestAsyncWithInterceptor(BidRequest bidRequest
#endif

private NimbusAdUnit RequestForNimbusAdUnit(BidRequest bidRequest, AdUnitType adUnitType) {
Debug.Log("BID REQUEST: " + JsonConvert.SerializeObject(bidRequest));
Task<string> responseJson;
try {
responseJson = MakeRequestAsyncWithInterceptor(bidRequest, adUnitType, AdUnitHelper.IsAdTypeFullScreen(adUnitType));
Expand Down

0 comments on commit 52bc6a6

Please sign in to comment.