Skip to content

Commit ba93c17

Browse files
authored
Merge branch 'main' into feat/always-send-sampled-flag
2 parents 16ca40c + 5aa047a commit ba93c17

24 files changed

+155
-73
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
- Add http.request.method attribute to http spans data ([#1633](https://github.com/getsentry/sentry-dart/pull/1633))
88
- Add db.system and db.name attributes to db spans data ([#1629](https://github.com/getsentry/sentry-dart/pull/1629))
9+
- Log SDK errors to the console if the log level is `fatal` even if `debug` is disabled ([#1635](https://github.com/getsentry/sentry-dart/pull/1635))
910

1011
### Features
1112

dart/lib/src/diagnostic_logger.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class DiagnosticLogger {
2626
}
2727

2828
bool _isEnabled(SentryLevel level) {
29-
return _options.debug && level.ordinal >= _options.diagnosticLevel.ordinal;
29+
return _options.debug &&
30+
level.ordinal >= _options.diagnosticLevel.ordinal ||
31+
level == SentryLevel.fatal;
3032
}
3133
}

dart/test/diagnostic_logger_test.dart

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import 'package:sentry/sentry.dart';
2+
import 'package:sentry/src/diagnostic_logger.dart';
3+
import 'package:test/test.dart';
4+
5+
void main() {
6+
late Fixture fixture;
7+
8+
setUp(() {
9+
fixture = Fixture();
10+
});
11+
12+
test('$DiagnosticLogger do not log if debug is disabled', () {
13+
fixture.options.debug = false;
14+
15+
fixture.getSut().log(SentryLevel.error, 'foobar');
16+
17+
expect(fixture.loggedMessage, isNull);
18+
});
19+
20+
test('$DiagnosticLogger log if debug is enabled', () {
21+
fixture.options.debug = true;
22+
23+
fixture.getSut().log(SentryLevel.error, 'foobar');
24+
25+
expect(fixture.loggedMessage, 'foobar');
26+
});
27+
28+
test('$DiagnosticLogger do not log if level is too low', () {
29+
fixture.options.debug = true;
30+
fixture.options.diagnosticLevel = SentryLevel.error;
31+
32+
fixture.getSut().log(SentryLevel.warning, 'foobar');
33+
34+
expect(fixture.loggedMessage, isNull);
35+
});
36+
37+
test('$DiagnosticLogger always log fatal', () {
38+
fixture.options.debug = false;
39+
40+
fixture.getSut().log(SentryLevel.fatal, 'foobar');
41+
42+
expect(fixture.loggedMessage, 'foobar');
43+
});
44+
}
45+
46+
class Fixture {
47+
var options = SentryOptions();
48+
49+
Object? loggedMessage;
50+
51+
DiagnosticLogger getSut() {
52+
return DiagnosticLogger(mockLogger, options);
53+
}
54+
55+
void mockLogger(
56+
SentryLevel level,
57+
String message, {
58+
String? logger,
59+
Object? exception,
60+
StackTrace? stackTrace,
61+
}) {
62+
loggedMessage = message;
63+
}
64+
}

flutter/analysis_options.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
include: package:flutter_lints/flutter.yaml
22

33
analyzer:
4+
exclude:
5+
- test/*.mocks.dart
46
language:
57
strict-casts: true
68
strict-inference: true

flutter/ffi-cocoa.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: SentryCocoa
22
description: Sentry Cocoa SDK FFI binding.
33
language: objc
4-
output: lib/src/sentry_cocoa.dart
4+
output: lib/src/native/cocoa/binding.dart
55
headers:
66
entry-points:
77
- ./cocoa_bindings_temp/Sentry.framework/Versions/A/PrivateHeaders/PrivateSentrySDKOnly.h

flutter/lib/src/event_processor/native_app_start_event_processor.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import 'dart:async';
22

33
import 'package:sentry/sentry.dart';
44

5-
import '../sentry_native.dart';
6-
import '../sentry_native_channel.dart';
5+
import '../native/sentry_native.dart';
76

87
/// EventProcessor that enriches [SentryTransaction] objects with app start
98
/// measurement.

flutter/lib/src/integrations/native_app_start_integration.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import 'package:flutter/scheduler.dart';
22
import 'package:sentry/sentry.dart';
33

44
import '../sentry_flutter_options.dart';
5-
import '../sentry_native.dart';
5+
import '../native/sentry_native.dart';
66
import '../event_processor/native_app_start_event_processor.dart';
77

88
/// Integration which handles communication with native frameworks in order to

0 commit comments

Comments
 (0)