Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Passing Sentry diagnostic level to iOS native layer #281

Merged
merged 3 commits into from
Aug 23, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions src/Sentry.Unity.Editor.iOS/NativeOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal string Generate(SentryOptions options)
NSDictionary* options = @{{
@""dsn"" : @""{options.Dsn}"",
@""debug"" : @{ToObjCString(options.Debug)},
@""diagnosticLevel"" : @{ToNativeDiagnosticLevel(options.DiagnosticLevel)},
@""diagnosticLevel"" : @""{ToNativeDiagnosticLevel(options.DiagnosticLevel)}"",
@""maxBreadcrumbs"": @{options.MaxBreadcrumbs},
@""maxCacheItems"": @{options.MaxCacheItems},
@""enableAutoSessionTracking"": @NO,
Expand All @@ -40,13 +40,17 @@ internal string Generate(SentryOptions options)

private static string ToObjCString(bool b) => b ? "YES" : "NO";

// Native Diagnostic Level:
// None = 0
// Debug = 1
// Info = 2
// Warning = 3
// Error = 4
// Fatal = 5
private static int ToNativeDiagnosticLevel(SentryLevel diagnosticLevel) => (int)diagnosticLevel + 1;
private static string ToNativeDiagnosticLevel(SentryLevel sentryLevel)
{
return sentryLevel switch
{
SentryLevel.Debug => "debug",
SentryLevel.Info => "info",
SentryLevel.Warning => "warning",
SentryLevel.Error => "error",
SentryLevel.Fatal => "fatal",
_ => "none"
};
}
}
}