Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ jobs:
- name: Download pub dependencies
run: flutter pub get

- name: Download example pub dependencies
run: flutter pub get
working-directory: example

- name: Run analyzer
run: flutter analyze

Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 6.0.1

- Add an example app.

# 6.0.0

- Bump flutter_bugfender version to 5.0.0
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

A library helping integrate Bugfender with the [logging] package.

See the [example app][example] for a runnable version of the snippets below.

## Usage

### Setup
Expand Down Expand Up @@ -108,6 +110,7 @@ We are **top-tier experts** focused on Flutter Enterprise solutions.
[build-badge]: https://img.shields.io/github/actions/workflow/status/leancodepl/logging_bugfender/test.yml?branch=master
[build-badge-link]: https://github.com/leancodepl/logging_bugfender/actions/workflows/test.yml
[logging]: https://pub.dev/packages/logging
[example]: https://github.com/leancodepl/logging_bugfender/tree/master/example
[banner-img]: https://raw.githubusercontent.com/leancodepl/logging_bugfender/refs/heads/master/docs/imgs/banner.png
[leancode-landing]: https://leancode.co/?utm_source=github.com&utm_medium=referral&utm_campaign=logging-bugfender
[leancode-estimate]: https://leancode.co/get-estimate?utm_source=github.com&utm_medium=referral&utm_campaign=logging-bugfender
Expand Down
1 change: 1 addition & 0 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include: package:leancode_lint/analysis_options.yaml
108 changes: 108 additions & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// An example app showing how to wire `logging_bugfender` into a Flutter app.
//
// This directory ships without the platform folders – run `flutter create .`
// in it once before `flutter run`.

import 'package:flutter/material.dart';
import 'package:logging/logging.dart';
import 'package:logging_bugfender/logging_bugfender.dart';

/// The key under which the signed in user is reported to Bugfender.
const usernameKey = 'username';

void main() {
// During debugging, you'll usually want to log everything. On production,
// `Level.INFO` and above is usually enough.
Logger.root.level = Level.ALL;

final loggingListener = LoggingBugfenderListener(
'my-very-secret-app-key',
// Logs are only sent to Bugfender by default – printing them to the
// console too is handy while debugging.
consolePrintStrategy: const PlainTextPrintStrategy(),
)..listen(Logger.root);

runApp(ExampleApp(loggingListener: loggingListener));
}

class ExampleApp extends StatelessWidget {
const ExampleApp({super.key, required this.loggingListener});

final LoggingBugfenderListener loggingListener;

@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'logging_bugfender example',
home: ExamplePage(loggingListener: loggingListener),
);
}
}

class ExamplePage extends StatefulWidget {
const ExamplePage({super.key, required this.loggingListener});

final LoggingBugfenderListener loggingListener;

@override
State<ExamplePage> createState() => _ExamplePageState();
}

class _ExamplePageState extends State<ExamplePage> {
/// Every class that logs should have its own [Logger] – its name is included
/// in the log message, so you always know where a record came from.
final _logger = Logger('ExamplePage');

bool _signedIn = false;

/// Custom data is attached to every log sent from this device, which makes
/// it easy to tell whose session you're looking at in the Bugfender console.
Future<void> _toggleSignIn() async {
final signedIn = _signedIn;

try {
if (signedIn) {
await widget.loggingListener.removeCustomData(usernameKey);
} else {
await widget.loggingListener.setCustomData(usernameKey, 'jane.doe');
}
} catch (err, st) {
// Both the error and the stack trace are sent to Bugfender.
_logger.severe('Failed updating the custom data', err, st);
return;
}

_logger.info(signedIn ? 'Signed out' : 'Signed in');

if (mounted) {
setState(() => _signedIn = !signedIn);
}
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('logging_bugfender')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
FilledButton(
onPressed: () => _logger.fine('The details button was tapped'),
child: const Text('Log at FINE'),
),
FilledButton(
onPressed: () => _logger.warning('The cache is almost full'),
child: const Text('Log at WARNING'),
),
const SizedBox(height: 16),
FilledButton(
onPressed: _toggleSignIn,
child: Text(_signedIn ? 'Sign out' : 'Sign in'),
),
],
),
),
);
}
}
20 changes: 20 additions & 0 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: logging_bugfender_example
description: An example app showing how to integrate Bugfender with the logging package.
publish_to: none

environment:
sdk: '>=3.3.0 <4.0.0'
flutter: '>=3.19.0'

dependencies:
flutter:
sdk: flutter
logging: ^1.0.2
logging_bugfender:
path: ../

dev_dependencies:
leancode_lint: '>=2.1.0 <2.2.0'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2? Not 25? 🤔

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the constraint used by the main package as well; upgrading lints will also force us to change SDK constraints and other stuff – for later 😛

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😱


flutter:
uses-material-design: true
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: logging_bugfender
description: A library helping integrate Bugfender with the logging package.
version: 6.0.0
version: 6.0.1
homepage: https://github.com/leancodepl/logging_bugfender

environment:
Expand Down
Loading