forked from xamarin/GoogleApisForiOSComponents
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExtensions.cs
More file actions
51 lines (41 loc) · 1.4 KB
/
Extensions.cs
File metadata and controls
51 lines (41 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using ObjCRuntime;
namespace Firebase.Crashlytics {
public partial class Crashlytics {
static string currentVersion;
public static string CurrentVersion {
get {
if (currentVersion == null) {
IntPtr RTLD_MAIN_ONLY = Dlfcn.dlopen (null, 0);
IntPtr ptr = Dlfcn.dlsym (RTLD_MAIN_ONLY, "FirebaseCrashlyticsVersionString");
currentVersion = Marshal.PtrToStringAnsi (ptr);
Dlfcn.dlclose (RTLD_MAIN_ONLY);
}
return currentVersion;
}
}
public void LogCallerInformation (string message, string className = "", [CallerFilePath] string filePath = "", [CallerMemberName] string memberName = "", [CallerLineNumber] int lineNumber = 0)
{
var logBuilder = new StringBuilder ();
if (!string.IsNullOrWhiteSpace (filePath)) {
var filename = Path.GetFileName (filePath);
logBuilder.Append ($"{filename}: ");
}
var isMemberNameEmpty = string.IsNullOrWhiteSpace (memberName);
if (!string.IsNullOrWhiteSpace (className)) {
logBuilder.Append ($"{className}");
logBuilder.Append (isMemberNameEmpty ? " " : ".");
}
if (!isMemberNameEmpty)
logBuilder.Append ($"{memberName} ");
if (lineNumber > 0)
logBuilder.Append ($"line {lineNumber} ");
logBuilder.Append ($"$ {message}");
Log (logBuilder.ToString ());
}
}
}