From 32e7a60d4fb9d49451b8407cf614a6499670d8db Mon Sep 17 00:00:00 2001 From: ndesai Date: Thu, 1 Aug 2024 10:50:56 -0500 Subject: [PATCH 1/2] feat: Log Forwarding and ANR reporting through android sdk. --- README.md | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b807e4f..c4d1be1 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ In your Unity IDE, click Tools → NewRelic → Getting Started to open the NewR dependencies { implementation project(':unityLibrary') implementation 'com.newrelic.agent.android:agent-ndk:1.+' - implementation 'com.newrelic.agent.android:android-agent:7.2.0' + implementation 'com.newrelic.agent.android:android-agent:7.5.0' } android { @@ -89,7 +89,7 @@ android { // See which Gradle version is preinstalled with Unity here https://docs.unity3d.com/Manual/android-gradle-overview.html // See official Gradle and Android Gradle Plugin compatibility table here https://developer.android.com/studio/releases/gradle-plugin#updating-gradle // To specify a custom Gradle version in Unity, go to "Preferences > External Tools", uncheck "Gradle Installed with Unity (recommended)" and specify a path to a custom Gradle version - classpath 'com.newrelic.agent.android:agent-gradle-plugin:7.3.0' + classpath 'com.newrelic.agent.android:agent-gradle-plugin:7.5.0' **BUILD_SCRIPT_DEPS** } } @@ -273,8 +273,54 @@ See the examples below, and for more detail, see [New Relic IOS SDK doc](https:/ NewRelicAgent.setMaxOfflineStorageSize(200); ``` +### LogInfo(String message) : void +> Logs an informational message to the New Relic log. +``` C# + NewRelicAgent.LogInfo("This is an informational message"); +``` + +### LogError(String message) : void +> Logs an error message to the New Relic log. +``` C# + NewRelicAgent.LogError("This is an error message"); +``` +### LogVerbose(String message) : void +> Logs a verbose message to the New Relic log. +``` C# + NewRelicAgent.LogVerbose("This is a verbose message"); +``` + +### LogWarning(String message) : void +> Logs a warning message to the New Relic log. +``` C# + NewRelicAgent.LogWarning("This is a warning message"); +``` +### LogDebug(String message) : void +> Logs a debug message to the New Relic log. +``` C# + NewRelicAgent.LogDebug("This is a debug message"); +``` + +### Log(NewRelicAgent.AgentLogLevel level, String message) : void +> Logs a message to the New Relic log with a specified log level. +``` C# + NewRelicAgent.LogNewRelic.NewRelicAgent.AgentLogLevel.INFO, "This is an informational message"); +``` + +### LogAttributes(Dictionary attributes) : void +> Logs a message with attributes to the New Relic log. +``` C# + NewRelicAgent.LogAttributes(new Dictionary() + { + {"BreadNumValue", 12.3 }, + {"BreadStrValue", "UnityBread" }, + {"BreadBoolValue", true }, + {"message", "This is a message with attributes" } + } + ); +``` ## How to see C# Errors(Fatal/Non Fatal) in NewRelic One? From 5b9d3bebad74989caa34362d68a6e8008e92a5d4 Mon Sep 17 00:00:00 2001 From: ndesai Date: Mon, 30 Sep 2024 16:26:00 -0500 Subject: [PATCH 2/2] fix: log attributes method is throwing expection in android --- CHANGELOG.md | 9 ++++ .../Editor/TestUnityDependencies.xml | 6 +-- com.newrelic.agent/Scripts/NewRelicAgent.cs | 45 ++++++++++++++++++- package.json | 2 +- 4 files changed, 57 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dfb65fb..153f57f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +## 1.4.1 + + +## Improvements + +- Native Android agent updated to version 7.6.0 +- Native iOS agent updated to version 7.5.2 +- Bug fixes for Log Attributes method + ## 1.4.0 ## New Features diff --git a/com.newrelic.agent/Editor/TestUnityDependencies.xml b/com.newrelic.agent/Editor/TestUnityDependencies.xml index e1a77f9..1b3b8dd 100644 --- a/com.newrelic.agent/Editor/TestUnityDependencies.xml +++ b/com.newrelic.agent/Editor/TestUnityDependencies.xml @@ -1,11 +1,11 @@ - - + + - + https://github.com/CocoaPods/Specs diff --git a/com.newrelic.agent/Scripts/NewRelicAgent.cs b/com.newrelic.agent/Scripts/NewRelicAgent.cs index e173551..ecfb8d9 100644 --- a/com.newrelic.agent/Scripts/NewRelicAgent.cs +++ b/com.newrelic.agent/Scripts/NewRelicAgent.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Threading; using UnityEngine.SceneManagement; +using System.Collections; #if UNITY_IPHONE || UNITY_ANDROID using NewRelic.Native; #endif @@ -749,7 +750,7 @@ static public void NoticeNetworkFailure(string url, { if (validatePluginImpl()) { - instance.agentInstance.noticeNetworkFailure(url, httpMethod, startTime,endTime, failureCode, message); + instance.agentInstance.noticeNetworkFailure(url, httpMethod, startTime, endTime, failureCode, message); } } @@ -1041,10 +1042,13 @@ static public void Log(NewRelicAgent.AgentLogLevel level, String message) { if (validatePluginImpl()) { + String logLevel = LogLevelString(level); instance.agentInstance.Log(level, message); } } + + /// /// Logs a set of attributes. /// @@ -1053,11 +1057,50 @@ static public void LogAttributes(Dictionary attributes) { if (validatePluginImpl()) { + + + + if ((attributes.ContainsKey("level") && attributes.GetValueOrDefault("level").GetType() == typeof(AgentLogLevel))) + { + attributes["level"] = LogLevelString((AgentLogLevel)attributes.GetValueOrDefault("level")); + } + + + instance.agentInstance.LogAttributes(attributes); } } + public static String LogLevelString(AgentLogLevel agentLogLevel) + { + + String logLevel = "INFO"; + + if (agentLogLevel.Equals(AgentLogLevel.DEBUG)) + { + logLevel = "DEBUG"; + } + else if (agentLogLevel.Equals(AgentLogLevel.ERROR)) + { + logLevel = "ERROR"; + } + else if (agentLogLevel.Equals(AgentLogLevel.INFO)) + { + logLevel = "INFO"; + } + else if (agentLogLevel.Equals(AgentLogLevel.VERBOSE)) + { + logLevel = "VERBOSE"; + } + else if (agentLogLevel.Equals(AgentLogLevel.WARNING)) + { + logLevel = "WARN"; + } + + + return logLevel; + } } } diff --git a/package.json b/package.json index 2a46ef6..fc0c72a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.newrelic.agent", - "version": "1.4.0", + "version": "1.4.1", "displayName": "NewRelic SDK", "description": "NewRelic's Unity SDK lets you bring the deep, introspective and native debugging power of NewRelic into your Unity game or application.", "unity": "2019.1",