Skip to content

Commit

Permalink
Change way of generating type in entries toJson
Browse files Browse the repository at this point in the history
  • Loading branch information
pdenert committed Nov 6, 2024
1 parent 19a77fd commit 5821653
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
2 changes: 2 additions & 0 deletions packages/patrol_log/lib/src/entry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ sealed class Entry with EquatableMixin {
}

final DateTime timestamp;

@JsonKey(includeToJson: true)
final EntryType type;

Map<String, dynamic> toJson();
Expand Down
6 changes: 0 additions & 6 deletions packages/patrol_log/lib/src/entry.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions packages/patrol_log/lib/src/log_entry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ class LogEntry extends Entry {
LogEntry({
required this.message,
DateTime? timestamp,
super.type = EntryType.log,
}) : super(timestamp: timestamp ?? DateTime.now());
}) : super(
timestamp: timestamp ?? DateTime.now(),
type: EntryType.log,
);

@override
factory LogEntry.fromJson(Map<String, dynamic> json) =>
Expand Down
6 changes: 4 additions & 2 deletions packages/patrol_log/lib/src/step_entry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ class StepEntry extends Entry {
this.exception,
this.data,
DateTime? timestamp,
super.type = EntryType.step,
}) : super(timestamp: timestamp ?? DateTime.now());
}) : super(
timestamp: timestamp ?? DateTime.now(),
type: EntryType.step,
);

factory StepEntry.fromJson(Map<String, dynamic> json) =>
_$StepEntryFromJson(json);
Expand Down
6 changes: 4 additions & 2 deletions packages/patrol_log/lib/src/test_entry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ class TestEntry extends Entry {
required this.status,
DateTime? timestamp,
this.error,
super.type = EntryType.test,
}) : super(timestamp: timestamp ?? DateTime.now());
}) : super(
timestamp: timestamp ?? DateTime.now(),
type: EntryType.test,
);

@override
factory TestEntry.fromJson(Map<String, dynamic> json) =>
Expand Down

0 comments on commit 5821653

Please sign in to comment.