-
Notifications
You must be signed in to change notification settings - Fork 329
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
76b4c9c
commit bcf5cb1
Showing
2 changed files
with
125 additions
and
111 deletions.
There are no files selected for viewing
123 changes: 123 additions & 0 deletions
123
packages/devtools_app/lib/src/screens/logging/logging_controls.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
// Copyright 2024 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'dart:async'; | ||
|
||
import 'package:devtools_app_shared/ui.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:provider/provider.dart'; | ||
|
||
import '../../service/service_extension_widgets.dart'; | ||
import '../../shared/analytics/constants.dart' as gac; | ||
import '../../shared/common_widgets.dart'; | ||
import '../../shared/primitives/utils.dart'; | ||
import '../../shared/ui/filter.dart'; | ||
import '../../shared/ui/search.dart'; | ||
import 'logging_controller.dart'; | ||
import 'shared/constants.dart'; | ||
|
||
class LoggingControls extends StatelessWidget { | ||
const LoggingControls({super.key}); | ||
|
||
static const filterQueryInstructions = ''' | ||
Type a filter query to show or hide specific logs. | ||
Any text that is not paired with an available filter key below will be queried against all categories (kind, message). | ||
Available filters: | ||
'kind', 'k' (e.g. 'k:flutter.frame', '-k:gc,stdout') | ||
Example queries: | ||
'my log message k:stdout,stdin' | ||
'flutter -k:gc' | ||
'''; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final controller = Provider.of<LoggingController>(context); | ||
final hasData = controller.filteredData.value.isNotEmpty; | ||
return Row( | ||
children: [ | ||
ClearButton( | ||
onPressed: controller.clear, | ||
gaScreen: gac.logging, | ||
gaSelection: gac.clear, | ||
minScreenWidthForTextBeforeScaling: loggingMinVerboseWidth, | ||
), | ||
const Spacer(), | ||
const SizedBox(width: denseSpacing), | ||
// TODO(kenz): fix focus issue when state is refreshed | ||
SearchField<LoggingController>( | ||
searchFieldWidth: isScreenWiderThan(context, loggingMinVerboseWidth) | ||
? wideSearchFieldWidth | ||
: defaultSearchFieldWidth, | ||
searchController: controller, | ||
searchFieldEnabled: hasData, | ||
), | ||
const SizedBox(width: denseSpacing), | ||
DevToolsFilterButton( | ||
onPressed: () { | ||
unawaited( | ||
showDialog( | ||
context: context, | ||
builder: (context) => FilterDialog<LogData>( | ||
controller: controller, | ||
queryInstructions: filterQueryInstructions, | ||
), | ||
), | ||
); | ||
}, | ||
isFilterActive: controller.isFilterActive, | ||
), | ||
const SizedBox(width: denseSpacing), | ||
CopyToClipboardControl( | ||
dataProvider: () => controller.filteredData.value | ||
.map((e) => '${e.timestamp} [${e.kind}] ${e.prettyPrinted()}') | ||
.joinWithTrailing('\n'), | ||
tooltip: 'Copy filtered logs', | ||
), | ||
const SizedBox(width: denseSpacing), | ||
SettingsOutlinedButton( | ||
gaScreen: gac.logging, | ||
gaSelection: gac.loggingSettings, | ||
tooltip: 'Logging Settings', | ||
onPressed: () { | ||
unawaited( | ||
showDialog( | ||
context: context, | ||
builder: (context) => const LoggingSettingsDialog(), | ||
), | ||
); | ||
}, | ||
), | ||
], | ||
); | ||
} | ||
} | ||
|
||
class LoggingSettingsDialog extends StatelessWidget { | ||
const LoggingSettingsDialog({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final theme = Theme.of(context); | ||
return DevToolsDialog( | ||
title: const DialogTitleText('Logging Settings'), | ||
content: Column( | ||
mainAxisSize: MainAxisSize.min, | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
...dialogSubHeader( | ||
theme, | ||
'General', | ||
), | ||
const StructuredErrorsToggle(), | ||
], | ||
), | ||
actions: const [ | ||
DialogCloseButton(), | ||
], | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters