From 8d68145cc5e007bfc662ef8bb436b716519f956e Mon Sep 17 00:00:00 2001
From: hxb <hxb@hdlchina.com.cn>
Date: 星期三, 14 六月 2023 12:01:41 +0800
Subject: [PATCH] 增加阿里云日志
---
AliyuLog/Transforms/Metadata.xml | 9
AliyuLog/Transforms/EnumMethods.xml | 13 +
HDL-ON_Android/Aliyu/AliyuLogProducerClient.cs | 133 +++++++++++++
HDL_APP_Project.sln | 14 +
AliyuLog/Jars/AboutJars.txt | 24 ++
HDL-ON_Android/Aliyu/Level.cs | 10 +
AliyuLog/Additions/AboutAdditions.txt | 48 ++++
HDL-ON_Android/Aliyu/AliyuLogUtil.cs | 98 +++++++++
HDL-ON_Android/HDL-ON_Android.csproj | 11 +
AliyuLog/Transforms/EnumFields.xml | 14 +
AliyuLog/Jars/aliyun-log-android-sdk-2.6.2.aar | 0
AliyuLog/Properties/AssemblyInfo.cs | 26 ++
AliyuLog/AliyuLog.csproj | 72 +++++++
HDL-ON_Android/Aliyu/LogBean.cs | 116 +++++++++++
14 files changed, 588 insertions(+), 0 deletions(-)
diff --git a/AliyuLog/Additions/AboutAdditions.txt b/AliyuLog/Additions/AboutAdditions.txt
new file mode 100644
index 0000000..89cbfbb
--- /dev/null
+++ b/AliyuLog/Additions/AboutAdditions.txt
@@ -0,0 +1,48 @@
+锘緼dditions allow you to add arbitrary C# to the generated classes
+before they are compiled. This can be helpful for providing convenience
+methods or adding pure C# classes.
+
+== Adding Methods to Generated Classes ==
+
+Let's say the library being bound has a Rectangle class with a constructor
+that takes an x and y position, and a width and length size. It will look like
+this:
+
+public partial class Rectangle
+{
+ public Rectangle (int x, int y, int width, int height)
+ {
+ // JNI bindings
+ }
+}
+
+Imagine we want to add a constructor to this class that takes a Point and
+Size structure instead of 4 ints. We can add a new file called Rectangle.cs
+with a partial class containing our new method:
+
+public partial class Rectangle
+{
+ public Rectangle (Point location, Size size) :
+ this (location.X, location.Y, size.Width, size.Height)
+ {
+ }
+}
+
+At compile time, the additions class will be added to the generated class
+and the final assembly will a Rectangle class with both constructors.
+
+
+== Adding C# Classes ==
+
+Another thing that can be done is adding fully C# managed classes to the
+generated library. In the above example, let's assume that there isn't a
+Point class available in Java or our library. The one we create doesn't need
+to interact with Java, so we'll create it like a normal class in C#.
+
+By adding a Point.cs file with this class, it will end up in the binding library:
+
+public class Point
+{
+ public int X { get; set; }
+ public int Y { get; set; }
+}
diff --git a/AliyuLog/AliyuLog.csproj b/AliyuLog/AliyuLog.csproj
new file mode 100644
index 0000000..7a96be7
--- /dev/null
+++ b/AliyuLog/AliyuLog.csproj
@@ -0,0 +1,72 @@
+锘�<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{3A0E9FF9-56B6-4323-9AE6-2B22975E399B}</ProjectGuid>
+ <ProjectTypeGuids>{10368E6C-D01B-4462-8E8B-01FC667A7035};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <TemplateGuid>{77efb91c-a7e9-4b0e-a7c5-31eeec3c6d46}</TemplateGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>AliyuLog</RootNamespace>
+ <AssemblyName>AliyuLog</AssemblyName>
+ <FileAlignment>512</FileAlignment>
+ <Deterministic>True</Deterministic>
+ <TargetFrameworkVersion>v8.0</TargetFrameworkVersion>
+ <AndroidClassParser>class-parse</AndroidClassParser>
+ <AndroidCodegenTarget>XAJavaInterop1</AndroidCodegenTarget>
+ <RestoreProjectStyle>PackageReference</RestoreProjectStyle>
+ <JavaMaximumHeapSize></JavaMaximumHeapSize>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>portable</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <AndroidHttpClientHandlerType></AndroidHttpClientHandlerType>
+ <JavaMaximumHeapSize></JavaMaximumHeapSize>
+ <AndroidHttpClientHandlerType></AndroidHttpClientHandlerType>
+ <JavaMaximumHeapSize></JavaMaximumHeapSize>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>portable</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Mono.Android" />
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Jars\AboutJars.txt" />
+ <None Include="Additions\AboutAdditions.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ <TransformFile Include="Transforms\Metadata.xml" />
+ <TransformFile Include="Transforms\EnumFields.xml" />
+ <TransformFile Include="Transforms\EnumMethods.xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <LibraryProjectZip Include="Jars\aliyun-log-android-sdk-2.6.2.aar" />
+ </ItemGroup>
+ <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.Bindings.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
diff --git a/AliyuLog/Jars/AboutJars.txt b/AliyuLog/Jars/AboutJars.txt
new file mode 100644
index 0000000..404cfd9
--- /dev/null
+++ b/AliyuLog/Jars/AboutJars.txt
@@ -0,0 +1,24 @@
+锘縏his directory is for Android .jars.
+
+There are 2 types of jars that are supported:
+
+== Input Jar ==
+
+This is the jar that bindings should be generated for.
+
+For example, if you were binding the Google Maps library, this would
+be Google's "maps.jar".
+
+Set the build action for these jars in the properties page to "InputJar".
+
+
+== Reference Jars ==
+
+These are jars that are referenced by the input jar. C# bindings will
+not be created for these jars. These jars will be used to resolve
+types used by the input jar.
+
+NOTE: Do not add "android.jar" as a reference jar. It will be added automatically
+based on the Target Framework selected.
+
+Set the build action for these jars in the properties page to "ReferenceJar".
diff --git a/AliyuLog/Jars/aliyun-log-android-sdk-2.6.2.aar b/AliyuLog/Jars/aliyun-log-android-sdk-2.6.2.aar
new file mode 100644
index 0000000..57162d2
--- /dev/null
+++ b/AliyuLog/Jars/aliyun-log-android-sdk-2.6.2.aar
Binary files differ
diff --git a/AliyuLog/Properties/AssemblyInfo.cs b/AliyuLog/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..261208f
--- /dev/null
+++ b/AliyuLog/Properties/AssemblyInfo.cs
@@ -0,0 +1,26 @@
+锘縰sing System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using Android.App;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("AliyuLog")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("AliyuLog")]
+[assembly: AssemblyCopyright("Copyright 漏 2018")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+[assembly: ComVisible(false)]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/AliyuLog/Transforms/EnumFields.xml b/AliyuLog/Transforms/EnumFields.xml
new file mode 100644
index 0000000..f31a96e
--- /dev/null
+++ b/AliyuLog/Transforms/EnumFields.xml
@@ -0,0 +1,14 @@
+锘�<enum-field-mappings>
+ <!--
+ This example converts the constants Fragment_id, Fragment_name,
+ and Fragment_tag from android.support.v4.app.FragmentActivity.FragmentTag
+ to an enum called Android.Support.V4.App.FragmentTagType with values
+ Id, Name, and Tag.
+
+ <mapping jni-class="android/support/v4/app/FragmentActivity$FragmentTag" clr-enum-type="Android.Support.V4.App.FragmentTagType">
+ <field jni-name="Fragment_name" clr-name="Name" value="0" />
+ <field jni-name="Fragment_id" clr-name="Id" value="1" />
+ <field jni-name="Fragment_tag" clr-name="Tag" value="2" />
+ </mapping>
+ -->
+</enum-field-mappings>
diff --git a/AliyuLog/Transforms/EnumMethods.xml b/AliyuLog/Transforms/EnumMethods.xml
new file mode 100644
index 0000000..f2bca37
--- /dev/null
+++ b/AliyuLog/Transforms/EnumMethods.xml
@@ -0,0 +1,13 @@
+锘�<enum-method-mappings>
+ <!--
+ This example changes the Java method:
+ android.support.v4.app.Fragment.SavedState.writeToParcel (int flags)
+ to be:
+ android.support.v4.app.Fragment.SavedState.writeToParcel (Android.OS.ParcelableWriteFlags flags)
+ when bound in C#.
+
+ <mapping jni-class="android/support/v4/app/Fragment.SavedState">
+ <method jni-name="writeToParcel" parameter="flags" clr-enum-type="Android.OS.ParcelableWriteFlags" />
+ </mapping>
+ -->
+</enum-method-mappings>
diff --git a/AliyuLog/Transforms/Metadata.xml b/AliyuLog/Transforms/Metadata.xml
new file mode 100644
index 0000000..91493a2
--- /dev/null
+++ b/AliyuLog/Transforms/Metadata.xml
@@ -0,0 +1,9 @@
+锘�<metadata>
+ <!--
+ This sample removes the class: android.support.v4.content.AsyncTaskLoader.LoadTask:
+ <remove-node path="/api/package[@name='android.support.v4.content']/class[@name='AsyncTaskLoader.LoadTask']" />
+
+ This sample removes the method: android.support.v4.content.CursorLoader.loadInBackground:
+ <remove-node path="/api/package[@name='android.support.v4.content']/class[@name='CursorLoader']/method[@name='loadInBackground']" />
+ -->
+</metadata>
diff --git a/HDL-ON_Android/Aliyu/AliyuLogProducerClient.cs b/HDL-ON_Android/Aliyu/AliyuLogProducerClient.cs
new file mode 100644
index 0000000..2aa9a47
--- /dev/null
+++ b/HDL-ON_Android/Aliyu/AliyuLogProducerClient.cs
@@ -0,0 +1,133 @@
+锘縰sing System;
+using Android.Content;
+using Com.Aliyun.Sls.Android.Producer;
+using Java.IO;
+
+namespace HDL_ON_Android.Aliyu
+{
+ public class AliyuLogProducerClient : Java.Lang.Object, ILogProducerCallback
+ {
+ private static string TAG = "ProducerClient";
+ LogProducerClient client = null;
+ private Context context;
+ protected string endpoint;
+ protected string logProject;
+ protected string logStore;
+ protected string accessKeyId;
+ protected string accessKeySecret;
+ protected string accessKeyToken;
+ protected string pluginAppId;
+
+ public AliyuLogProducerClient(Context context, string endpoint, string logProject, string logStore, string accessKeyId, string accessKeySecret, string accessKeyToken, string pluginAppId)
+ {
+ this.context = context;
+ this.endpoint = endpoint;
+ this.logProject = logProject;
+ this.logStore = logStore;
+ this.accessKeyId = accessKeyId;
+ this.accessKeySecret = accessKeySecret;
+ this.accessKeyToken = accessKeyToken;
+ this.pluginAppId = pluginAppId;
+ }
+
+
+ public void initProducer()
+ {
+ try
+ {
+ // endpoint 蹇呴』鏄互 https:// 鎴� http:// 寮�澶寸殑閾炬帴
+ string endpoint = this.endpoint;
+ string project = this.logProject;
+ string logstore = this.logStore;
+ string accessKeyId = this.accessKeyId;
+ string accessKeySecret = this.accessKeySecret;
+ string accessKeyToken = this.accessKeyToken;
+
+ LogProducerConfig config = new LogProducerConfig(context, endpoint, project, logstore, accessKeyId, accessKeySecret, accessKeyToken);
+ // 璁剧疆涓婚
+ config.SetTopic("test_topic");
+ // 璁剧疆tag淇℃伅锛屾tag浼氶檮鍔犲湪姣忔潯鏃ュ織涓�
+ config.AddTag("test", "test_tag");
+ // 姣忎釜缂撳瓨鐨勬棩蹇楀寘鐨勫ぇ灏忎笂闄愶紝鍙栧�间负1~5242880锛屽崟浣嶄负瀛楄妭銆傞粯璁や负1024 * 1024
+ config.SetPacketLogBytes(1024 * 1024);
+ // 姣忎釜缂撳瓨鐨勬棩蹇楀寘涓寘鍚棩蹇楁暟閲忕殑鏈�澶у�硷紝鍙栧�间负1~4096锛岄粯璁や负1024
+ config.SetPacketLogCount(1024);
+ // 琚紦瀛樻棩蹇楃殑鍙戦�佽秴鏃舵椂闂达紝濡傛灉缂撳瓨瓒呮椂锛屽垯浼氳绔嬪嵆鍙戦�侊紝鍗曚綅涓烘绉掞紝榛樿涓�3000
+ config.SetPacketTimeout(3000);
+ // 鍗曚釜Producer Client瀹炰緥鍙互浣跨敤鐨勫唴瀛樼殑涓婇檺锛岃秴鍑虹紦瀛樻椂add_log鎺ュ彛浼氱珛鍗宠繑鍥炲け璐�
+ // 榛樿涓�64 * 1024 * 1024
+ config.SetMaxBufferLimit(64 * 1024 * 1024);
+ // 鍙戦�佺嚎绋嬫暟锛岄粯璁や负1
+ config.SetSendThreadCount(1);
+
+ //缃戠粶杩炴帴瓒呮椂鏃堕棿锛屾暣鏁帮紝鍗曚綅绉掞紝榛樿涓�10
+ config.SetConnectTimeoutSec(10);
+ //鏃ュ織鍙戦�佽秴鏃舵椂闂达紝鏁存暟锛屽崟浣嶇锛岄粯璁や负15
+ config.SetSendTimeoutSec(10);
+ //flusher绾跨▼閿�姣佹渶澶х瓑寰呮椂闂达紝鏁存暟锛屽崟浣嶇锛岄粯璁や负1
+ config.SetDestroyFlusherWaitSec(2);
+ //sender绾跨▼姹犻攢姣佹渶澶х瓑寰呮椂闂达紝鏁存暟锛屽崟浣嶇锛岄粯璁や负1
+ config.SetDestroySenderWaitSec(2);
+ //鏁版嵁涓婁紶鏃剁殑鍘嬬缉绫诲瀷锛岄粯璁や负LZ4鍘嬬缉锛�0 涓嶅帇缂╋紝1 LZ4鍘嬬缉锛岄粯璁や负1
+ config.SetCompressType(1);
+ //璁惧鏃堕棿涓庢爣鍑嗘椂闂翠箣宸紝鍊间负鏍囧噯鏃堕棿-璁惧鏃堕棿锛屼竴鑸绉嶆儏鍐电敤鎴峰鎴风璁惧鏃堕棿涓嶅悓姝ョ殑鍦烘櫙
+ //鏁存暟锛屽崟浣嶇锛岄粯璁や负0锛涙瘮濡傚綋鍓嶈澶囨椂闂翠负1607064208, 鏍囧噯鏃堕棿涓�1607064308锛屽垯鍊艰缃负 1607064308 - 1607064208 = 10
+ config.SetNtpTimeOffset(3);
+ //鏃ュ織鏃堕棿涓庢湰鏈烘椂闂翠箣宸紝瓒呰繃璇ュぇ灏忓悗浼氭牴鎹� `drop_delay_log` 閫夐」杩涜澶勭悊銆�
+ //涓�鑸绉嶆儏鍐靛彧浼氬湪璁剧疆persistent鐨勬儏鍐典笅鍑虹幇锛屽嵆璁惧涓嬬嚎鍚庯紝瓒呰繃鍑犲ぉ/鏁版湀鍚姩锛屽彂閫侀��鍑哄墠鏈彂鍑虹殑鏃ュ織
+ //鏁存暟锛屽崟浣嶇锛岄粯璁や负7*24*3600锛屽嵆7澶�
+ config.SetMaxLogDelayTime(7 * 24 * 3600);
+ //瀵逛簬瓒呰繃 `max_log_delay_time` 鏃ュ織鐨勫鐞嗙瓥鐣�
+ //0 涓嶄涪寮冿紝鎶婃棩蹇楁椂闂翠慨鏀逛负褰撳墠鏃堕棿; 1 涓㈠純锛岄粯璁や负 1 锛堜涪寮冿級
+ config.SetDropDelayLog(0);
+ //鏄惁涓㈠純閴存潈澶辫触鐨勬棩蹇楋紝0 涓嶄涪寮冿紝1涓㈠純
+ //榛樿涓� 0锛屽嵆涓嶄涪寮�
+ config.SetDropUnauthorizedLog(0);
+ // 鏄惁浣跨敤涓荤嚎绋嬪洖璋�
+ // false: 浣跨敤涓荤嚎绋嬪洖璋冦�傚洖璋冧細鍦ㄤ富绾跨▼涓婃墽琛岋紝涓旀瘡涓� client 閮芥湁鑷繁鍗曠嫭鐨勫洖璋冦��
+ // true: 浣跨敤 sender 绾跨▼鍥炶皟銆傚洖璋冧細鍦� sender 鐜板憟涓婃墽琛岋紝姣忔鎵ц鍥炶皟鏃堕兘浼� attach 涓�涓柊鐨� java 绾跨▼锛屾墍鏈� client 鍏辩敤涓�涓洖璋冦��
+ // 娉ㄦ剰锛氶粯璁や娇鐢� sender 绾跨▼鍥炶皟銆�
+ config.SetCallbackFromSenderThread(false);
+
+ /**
+ * 浠ヤ笅涓哄紑鍚柇鐐圭画浼犵殑閰嶇疆, 鎸夌収濡備笅閰嶇疆寮�鍚柇鐐圭画浼犲姛鑳藉悗, 鏃ュ織浼氬厛缂撳瓨鍒版湰鍦�
+ */
+ // 1 寮�鍚柇鐐圭画浼犲姛鑳斤紝 0 鍏抽棴
+ // 姣忔鍙戦�佸墠浼氭妸鏃ュ織淇濆瓨鍒版湰鍦扮殑binlog鏂囦欢锛屽彧鏈夊彂閫佹垚鍔熸墠浼氬垹闄わ紝淇濊瘉鏃ュ織涓婁紶At Least Once
+ config.SetPersistent(1);
+ // 鎸佷箙鍖栫殑鏂囦欢鍚嶏紝闇�瑕佷繚璇佹枃浠舵墍鍦ㄧ殑鏂囦欢澶瑰凡鍒涘缓銆�
+ // !!!!!!!!!!!!!!!!!!!娉ㄦ剰!!!!!!!!!!!!!!!!!!!
+ // 閰嶇疆澶氫釜瀹㈡埛绔椂锛屼笉搴旇缃浉鍚屾枃浠�
+ config.SetPersistentFilePath(context.FilesDir + string.Format("%slog_data.dat", File.Separator));
+ // 鏄惁姣忔AddLog寮哄埗鍒锋柊锛岄珮鍙潬鎬у満鏅缓璁墦寮�
+ config.SetPersistentForceFlush(0);
+ // 鎸佷箙鍖栨枃浠舵粴鍔ㄤ釜鏁帮紝寤鸿璁剧疆鎴�10銆�
+ config.SetPersistentMaxFileCount(10);
+ // 姣忎釜鎸佷箙鍖栨枃浠剁殑澶у皬锛屽缓璁缃垚1-10M
+ config.SetPersistentMaxFileSize(1024 * 1024);
+ // 鏈湴鏈�澶氱紦瀛樼殑鏃ュ織鏁帮紝涓嶅缓璁秴杩�1M锛岄�氬父璁剧疆涓�65536鍗冲彲
+ config.SetPersistentMaxLogCount(65536);
+
+ client = new LogProducerClient(config, this);
+ }
+ catch (LogProducerException e)
+ {
+
+ }
+
+ }
+ public void sendLog(Log log)
+ {
+ LogProducerResult result = client.AddLog(log);
+ }
+ //callback涓哄彲閫夐厤缃�, 濡傛灉涓嶉渶瑕佸叧娉ㄦ棩蹇楃殑鍙戦�佹垚鍔熸垨澶辫触鐘舵��, 鍙互涓嶆敞鍐� callback
+ public void OnCall(int resultCode, string reqId, string errorMessage, int logBytes, int compressedBytes)
+ {
+ // // resultCode: 鐘舵�佺爜, 璇﹁ LogProducerResult
+ // // reqId: 璇锋眰Id, 宸茬粡搴熷純
+ // // errorMessage: 澶辫触淇℃伅
+ // // logBytes: 鏃ュ織鍘熷瀛楄妭鏁�
+ // // compressedBytes: 鏃ュ織鍘嬬缉瀛楄妭鏁�
+ }
+ }
+}
\ No newline at end of file
diff --git a/HDL-ON_Android/Aliyu/AliyuLogUtil.cs b/HDL-ON_Android/Aliyu/AliyuLogUtil.cs
new file mode 100644
index 0000000..33614d0
--- /dev/null
+++ b/HDL-ON_Android/Aliyu/AliyuLogUtil.cs
@@ -0,0 +1,98 @@
+锘縰sing System;
+using Android.Content;
+using Com.Aliyun.Sls.Android.Producer;
+
+namespace HDL_ON_Android.Aliyu
+{
+ public class AliyuLogUtil
+ {
+ private static AliyuLogProducerClient exceptionProducerClient;
+
+ private static LogBean logBean;
+
+ private static AliyuLogProducerClient getExceptionProducerClient()
+ {
+ lock (exceptionProducerClient)
+ {
+ if (exceptionProducerClient == null)
+ {
+ exceptionProducerClient = new AliyuLogProducerClient(Shared.Application.Activity, "https://cn-hangzhou.log.aliyuncs.com", "log", "event_tracking", "LTAI5tLzDxrtsFyi3xtK3YWt", "eX31JZrRAvC2wZWPiZU0SYhlfAUMoT", null, null);
+ exceptionProducerClient.initProducer();
+ }
+ return exceptionProducerClient;
+ }
+ }
+
+
+ /**
+ * 寮傚父鏃ュ織
+ *
+ * @param title 鏍囬
+ * @param content 闄勫姞鏁版嵁鍐呭
+ * @param level 鎶ヨ绛夌骇
+ */
+ public static void log(string title, string content, Level level)
+ {
+ log(title, content, level, null);
+ }
+ /**
+ * 寮傚父鏃ュ織
+ *
+ * @param title 鏍囬
+ * @param content 闄勫姞鏁版嵁鍐呭
+ * @param otherMsg 鍏朵粬闄勫姞鏁版嵁锛屾病鏈夊彲涓虹┖
+ * @param level 鎶ヨ绛夌骇
+ * @param type 寮傚父绫诲瀷
+ */
+ public static void log(string title, string content, Level level, string type)
+ {
+ log(title, content, level, null, null);
+ }
+ /**
+ * 寮傚父鏃ュ織
+ *
+ * @param title 鏍囬
+ * @param content 闄勫姞鏁版嵁鍐呭
+ * @param otherMsg 鍏朵粬闄勫姞鏁版嵁锛屾病鏈夊彲涓虹┖
+ * @param level 鎶ヨ绛夌骇
+ * @param type 寮傚父绫诲瀷
+ * @param exceptionBlock 寮傚父浠g爜鍧�
+ */
+ public static void log(string title, string content, Level level, string type, string exceptionBlock)
+ {
+ /**
+ * 娌℃湁homeId鍜寀serId 涓嶅厑璁镐笂浼� 鍙笂浼犱綇瀹呴噷闈㈢殑寮傚父 鍑忓皯浜戠鍘嬪姏
+ * 1.鐐瑰嚮椤圭洰鐨勬椂鍊欒缃�
+ * 2.鍏抽棴浣忓畢椤甸潰鐨勬椂鍊欏幓鎺�
+ */
+ if (string.IsNullOrEmpty(getLogBean().getUserId()) || string.IsNullOrEmpty(getLogBean().getHomeId()))
+ {
+ return;
+ }
+ Log log = new Log();
+ log.PutContent("title", title);
+ log.PutContent("content", content);
+ log.PutContent("level", level.ToString());
+ log.PutContent("userId", getLogBean().getUserId());
+ log.PutContent("homeId", getLogBean().getHomeId());
+ log.PutContent("time", System.DateTime.UtcNow + "");
+ log.PutContent("userAgent", getLogBean().getUserAgent());
+ log.PutContent("appVersion", getLogBean().getAppVersion());
+ log.PutContent("type", type);
+ log.PutContent("exceptionBlock", exceptionBlock);
+ getExceptionProducerClient().sendLog(log);
+ }
+
+ public static LogBean getLogBean()
+ {
+ lock (logBean)
+ {
+ if (null == logBean)
+ {
+ logBean = new LogBean();
+ }
+ return logBean;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/HDL-ON_Android/Aliyu/Level.cs b/HDL-ON_Android/Aliyu/Level.cs
new file mode 100644
index 0000000..729a6e6
--- /dev/null
+++ b/HDL-ON_Android/Aliyu/Level.cs
@@ -0,0 +1,10 @@
+锘縰sing System;
+namespace HDL_ON_Android.Aliyu
+{
+ public enum Level
+ {
+ high,//楂�
+ middle,//涓�
+ low//浣�
+ }
+}
diff --git a/HDL-ON_Android/Aliyu/LogBean.cs b/HDL-ON_Android/Aliyu/LogBean.cs
new file mode 100644
index 0000000..fa8025d
--- /dev/null
+++ b/HDL-ON_Android/Aliyu/LogBean.cs
@@ -0,0 +1,116 @@
+锘縰sing System;
+namespace HDL_ON_Android.Aliyu
+{
+ public class LogBean
+ {
+ /**
+ * 鐢ㄦ埛id锛岄潪蹇呭~
+ */
+ private string userId;
+ /**
+ * 浣忓畢id锛岄潪蹇呭~
+ */
+ private string homeId;
+ /**
+ * 缃戝叧mac锛岄潪蹇呭~
+ */
+ private string mac;
+ /**
+ * 鏍囬锛屽繀椤昏濉�
+ */
+ private string title;
+ /**
+ * 鏃ュ織鏃堕棿
+ */
+ private string time;
+ /**
+ * 绯荤粺锛欼OS銆丄ndroid銆乄indows銆佺綉鍏�
+ */
+ private string userAgent;
+ /**
+ * 杞欢鐗堟湰
+ */
+ private string appVersion;
+ private string type;
+
+ public string getUserId()
+ {
+ return userId == null ? "" : userId;
+ }
+
+
+ public string getHomeId()
+ {
+ return homeId == null ? "" : homeId;
+ }
+
+ public void setUserId(string userId)
+ {
+ this.userId = userId;
+ }
+
+ public void setHomeId(string homeId)
+ {
+ this.homeId = homeId;
+ }
+ public string getMac()
+ {
+ return mac;
+ }
+
+ public void setMac(string mac)
+ {
+ this.mac = mac;
+ }
+
+ public string getTitle()
+ {
+ return title;
+ }
+
+ public void setTitle(string title)
+ {
+ this.title = title;
+ }
+
+ public string getTime()
+ {
+ return time;
+ }
+
+ public void setTime(string time)
+ {
+ this.time = time;
+ }
+
+ public string getUserAgent()
+ {
+ return userAgent;
+ }
+
+ public void setUserAgent(string userAgent)
+ {
+ this.userAgent = userAgent;
+ }
+
+ public string getAppVersion()
+ {
+ return appVersion;
+ }
+
+ public void setAppVersion(string appVersion)
+ {
+ this.appVersion = appVersion;
+ }
+
+ public string getType()
+ {
+ return type;
+ }
+
+ public void setType(string type)
+ {
+ this.type = type;
+ }
+ }
+}
diff --git a/HDL-ON_Android/HDL-ON_Android.csproj b/HDL-ON_Android/HDL-ON_Android.csproj
index 361fa47..dd16ab7 100644
--- a/HDL-ON_Android/HDL-ON_Android.csproj
+++ b/HDL-ON_Android/HDL-ON_Android.csproj
@@ -227,6 +227,10 @@
<Compile Include="Zxing\ScanActivity.cs" />
<Compile Include="LeChengVideo\LeTest.cs" />
<Compile Include="Other\LocationUtils.cs" />
+ <Compile Include="Aliyu\AliyuLogUtil.cs" />
+ <Compile Include="Aliyu\AliyuLogProducerClient.cs" />
+ <Compile Include="Aliyu\LogBean.cs" />
+ <Compile Include="Aliyu\Level.cs" />
</ItemGroup>
<ItemGroup>
<AndroidAsset Include="Assets\agconnect-services.json" />
@@ -1643,6 +1647,13 @@
<Folder Include="Assets\Phone\FunctionIcon\Panel\" />
<Folder Include="Assets\Phone\FunctionIcon\Inverter\" />
<Folder Include="Assets\Phone\FunctionIcon\Electrical\MechanicalArm\" />
+ <Folder Include="Aliyu\" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\AliyuLog\AliyuLog.csproj">
+ <Project>{3A0E9FF9-56B6-4323-9AE6-2B22975E399B}</Project>
+ <Name>AliyuLog</Name>
+ </ProjectReference>
</ItemGroup>
<Import Project="..\HDL_ON\HDL_ON.projitems" Label="Shared" Condition="Exists('..\HDL_ON\HDL_ON.projitems')" />
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
diff --git a/HDL_APP_Project.sln b/HDL_APP_Project.sln
index 84800828..1426310 100644
--- a/HDL_APP_Project.sln
+++ b/HDL_APP_Project.sln
@@ -18,6 +18,8 @@
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UMSdk", "UMSdk\UMSdk.csproj", "{5CD1B2DE-1ABD-4B46-8C97-CCB6EA90346A}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AliyuLog", "AliyuLog\AliyuLog.csproj", "{3A0E9FF9-56B6-4323-9AE6-2B22975E399B}"
+EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
HDL_ON\HDL_ON.projitems*{09712674-2a38-407b-b1e2-560b2c352f9a}*SharedItemsImports = 4
@@ -119,6 +121,18 @@
{5CD1B2DE-1ABD-4B46-8C97-CCB6EA90346A}.Release|iPhone.Build.0 = Release|Any CPU
{5CD1B2DE-1ABD-4B46-8C97-CCB6EA90346A}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{5CD1B2DE-1ABD-4B46-8C97-CCB6EA90346A}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
+ {3A0E9FF9-56B6-4323-9AE6-2B22975E399B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {3A0E9FF9-56B6-4323-9AE6-2B22975E399B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {3A0E9FF9-56B6-4323-9AE6-2B22975E399B}.Debug|iPhone.ActiveCfg = Debug|Any CPU
+ {3A0E9FF9-56B6-4323-9AE6-2B22975E399B}.Debug|iPhone.Build.0 = Debug|Any CPU
+ {3A0E9FF9-56B6-4323-9AE6-2B22975E399B}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
+ {3A0E9FF9-56B6-4323-9AE6-2B22975E399B}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
+ {3A0E9FF9-56B6-4323-9AE6-2B22975E399B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {3A0E9FF9-56B6-4323-9AE6-2B22975E399B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {3A0E9FF9-56B6-4323-9AE6-2B22975E399B}.Release|iPhone.ActiveCfg = Release|Any CPU
+ {3A0E9FF9-56B6-4323-9AE6-2B22975E399B}.Release|iPhone.Build.0 = Release|Any CPU
+ {3A0E9FF9-56B6-4323-9AE6-2B22975E399B}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
+ {3A0E9FF9-56B6-4323-9AE6-2B22975E399B}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
--
Gitblit v1.8.0