Skip to content

Commit

Permalink
Merge pull request #21 from Frezyx/dev
Browse files Browse the repository at this point in the history
Release version 0.9.0
  • Loading branch information
Frezyx authored Apr 3, 2022
2 parents 88095bd + 2445e86 commit 21d6195
Show file tree
Hide file tree
Showing 28 changed files with 425 additions and 284 deletions.
36 changes: 16 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
<a href="https://pub.dev/packages/talker/score"><img src="https://badges.bar/talker/pub%20points" alt="Pub points"></a>
</p>
<h2 align="center">How it works?</h2>
<p align="center">
<img src="https://github.com/Frezyx/talker/blob/master/docs/assets/working_model.jpg?raw=true">
</p>
<p align="center">Here is the general scheme of the package and its main features</p>
<a href="https://www.figma.com/proto/uv7J8NiEVFSq1bLdPXb1aL/Talker?node-id=203%3A327&scaling=min-zoom&page-id=203%3A274&starting-point-node-id=203%3A275" align="center">
<img src="docs/assets/scheme.gif">
</a>

<h2 align="center">On All Platforms</h2>
<p align="center">
Expand All @@ -37,35 +38,36 @@ Follow these steps to use this package
### Add dependency
```yaml
dependencies:
talker: ^0.8.1
talker: ^0.9.0
```
### Easy to use
You can use Talker instance everywhere in your app <br>
Simple and concise syntax will help you with this
```dart

final talker = Talker();
// Handle exceptions and errors
try {
// your code...
} on Error catch (e, st) {
Talker.instance.handleError(e, st, 'Error in ...');
talker.handleError(e, st, 'Error in ...');
}

// Log your app info
Talker.instance.log('App is started'),
Talker.instance.error('App is started'),
Talker.instance.waring('App is started'),
talker.log('App is started'),
talker.error('App is started'),
talker.waring('App is started'),
///...
```
More examples you can get [there](https://github.com/Frezyx/talker/blob/master/packages/talker/example/talker_example.dart) or in [docs](https://github.com/Frezyx/talker/blob/master/packages/talker/lib/src/talker_interface.dart)

### Customization
Configure the error handler and logger for yourself
```dart
final talker = Talker();
// Handle exceptions and errors
Talker.instance.configure(
talker.configure(
/// Your own observers to handle errors's exception's and log's
observers: [],
settings: const TalkerSettings(
Expand All @@ -86,26 +88,20 @@ Often you need to check what happening in the application when there is no conso
### Add dependency
```yaml
dependencies:
talker: ^0.8.1
talker_flutter: ^0.8.1
talker: ^0.9.0
talker_flutter: ^0.9.0
```
### Easy to use
Add this code at something place of your Flutter application where you want to display logs
```dart
TalkerScreen(talker: Talker.instance)
final talker = Talker();
TalkerScreen(talker: talker)
```
### Result
<img src="https://github.com/Frezyx/talker/blob/master/docs/assets/talker_flutter_ios_screen.png?raw=true" width="50%">
#### TODO:
- LogLevel as a model with customization
- ErrorLevel as a model with customization
- Filter for logs in UI (talker_flutter)
- Flutter Talker customization / filters
- TalkerLogger settings using by Talker
- Remove additional field in TalkerDataInterface and all extended models
For help getting started with 😍 Flutter, view
[online documentation](https://flutter.dev/docs), which offers tutorials,
Expand Down
Binary file added docs/assets/scheme.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions packages/talker/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.9.0
- **BREAKING** Create common Talker constructor
- **BREAKING** After this version Talker is not singleton class
- **FEAT** Now you can create a lot of Talker instances for you app
- **FEAT** Now ***configure()*** method is not async

## 0.8.1
- **talker_logger** update to 0.8.0 version
- talker_logger changes:
Expand Down
36 changes: 18 additions & 18 deletions packages/talker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
<a href="https://pub.dev/packages/talker/score"><img src="https://badges.bar/talker/pub%20points" alt="Pub points"></a>
</p>
<h2 align="center">How it works?</h2>
<p align="center">
<img src="https://github.com/Frezyx/talker/blob/master/docs/assets/working_model.jpg?raw=true">
</p>
<p align="center">Here is the general scheme of the package and its main features</p>
<a href="https://www.figma.com/proto/uv7J8NiEVFSq1bLdPXb1aL/Talker?node-id=203%3A327&scaling=min-zoom&page-id=203%3A274&starting-point-node-id=203%3A275" align="center">
<img src="docs/assets/scheme.gif">
</a>

<h2 align="center">On All Platforms</h2>
<p align="center">
Expand All @@ -37,38 +38,41 @@ Follow these steps to use this package
### Add dependency
```yaml
dependencies:
talker: ^0.8.1
talker: ^0.9.0
```
### Easy to use
You can use Talker instance everywhere in your app <br>
Simple and concise syntax will help you with this
```dart

final talker = Talker();
// Handle exceptions and errors
try {
// your code...
} on Error catch (e, st) {
Talker.instance.handleError(e, st, 'Error in ...');
talker.handleError(e, st, 'Error in ...');
}

// Log your app info
Talker.instance.log('App is started'),
Talker.instance.error('App is started'),
Talker.instance.waring('App is started'),
talker.log('App is started'),
talker.error('App is started'),
talker.waring('App is started'),
///...
```
More examples you can get [there](https://github.com/Frezyx/talker/blob/master/packages/talker/example/talker_example.dart) or in [docs](https://github.com/Frezyx/talker/blob/master/packages/talker/lib/src/talker_interface.dart)

### Customization
Configure the error handler and logger for yourself
```dart
final talker = Talker();
// Handle exceptions and errors
Talker.instance.configure(
talker.configure(
/// Your own observers to handle errors's exception's and log's
observers: [],
settings: const TalkerSettings(
/// Your own registered types of error's exception's and log's
registeredTypes: [HttpTalkerLog],
maxHistoryItems: 1000,
useHistory: true,
useConsoleLogs: true,
Expand All @@ -84,24 +88,20 @@ Often you need to check what happening in the application when there is no conso
### Add dependency
```yaml
dependencies:
talker: ^0.8.1
talker_flutter: ^0.8.1
talker: ^0.9.0
talker_flutter: ^0.9.0
```
### Easy to use
Add this code at something place of your Flutter application where you want to display logs
```dart
TalkerScreen(talker: Talker.instance)
final talker = Talker();
TalkerScreen(talker: talker)
```
### Result
<img src="https://github.com/Frezyx/talker/blob/master/docs/assets/talker_flutter_ios_screen.png?raw=true" width="50%">
#### TODO:
- LogLevel as a model with customization
- ErrorLevel as a model with customization
- Filter for logs in UI (talker_flutter)
- Flutter Talker customization / filters
For help getting started with 😍 Flutter, view
[online documentation](https://flutter.dev/docs), which offers tutorials,
Expand Down
22 changes: 11 additions & 11 deletions packages/talker/example/talker_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class HttpTalkerLog extends TalkerLog {
}

Future<void> main() async {
await Talker.instance.configure(
final talker = Talker(
settings: TalkerSettings(
registeredTypes: [HttpTalkerLog],
),
Expand All @@ -22,27 +22,27 @@ Future<void> main() async {
try {
throw Exception('Test service exception');
} catch (e, st) {
Talker.instance.handle(e, st, 'Working with string error');
talker.handle(e, st, 'Working with string error');
}

try {
throw Exception('Service can`t get test data');
} on Exception catch (e, st) {
Talker.instance.handleException(e, st, 'Working with strings exception');
talker.handleException(e, st, 'Working with strings exception');
}

Talker.instance.log(
talker.log(
'Server error',
logLevel: LogLevel.critical,
);

Talker.instance.fine('Log fine');
Talker.instance.error('Log error');
Talker.instance.good('Log good');
Talker.instance.verbose('Log verbose');
Talker.instance.warning('Log warning');
Talker.instance.critical('Log critical');
talker.fine('Log fine');
talker.error('Log error');
talker.good('Log good');
talker.verbose('Log verbose');
talker.warning('Log warning');
talker.critical('Log critical');

final httpLog = HttpTalkerLog('Http good');
Talker.instance.logTyped(httpLog);
talker.logTyped(httpLog);
}
4 changes: 2 additions & 2 deletions packages/talker/lib/src/settings/talker_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ class TalkerSettings {
///}
///
///void main() {
/// Talker.instance.configure(
/// talker.configure(
/// settings: const TalkerSettings(
/// registeredTypes: [HttpTalkerLog],
/// ),
/// );
///
/// final httpLog = HttpTalkerLog('Http good');
/// Talker.instance.logTyped(httpLog);
/// talker.logTyped(httpLog);
/// }
/// ```
List<Type> get registeredTypes =>
Expand Down
76 changes: 56 additions & 20 deletions packages/talker/lib/src/talker.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,52 @@
import 'dart:async';
import 'package:talker/talker.dart';

/// Talker - advanced exception handling and logging
/// for dart/flutter applications
class Talker implements TalkerInterface {
Talker._() {
_settings = TalkerSettings();
_logger = TalkerLogger();
/// {@template talker_constructor}
/// Talker base constructor
///
/// You can set your own [TalkerLogger] [logger] subclass
/// (create your own class implements [TalkerLoggerInterface]),
/// [TalkerLogger()] used by default
///
/// You can edit package settings with [settings] [TalkerSettings],
/// [TalkerSettings()] used by default
///
/// You can set your own [TalkerLoggerSettings] [loggerSettings]
/// to customize talker logs,
///
/// You can set your own [TalkerLoggerFilter] [loggerFilter]
/// to filter talker logs,
///
/// You can set your own [LoggerFormater] [loggerFormater]
/// to format output of talker logs,
///
/// You can add your own observers to handle errors and logs in other place
/// [List<TalkerObserver>] [observers],
/// {@endtemplate}
Talker({
TalkerLogger? logger,
TalkerSettings? settings,
TalkerLoggerSettings? loggerSettings,
TalkerLoggerFilter? loggerFilter,
LoggerFormater? loggerFormater,
List<TalkerObserver>? observers,
}) {
_settings = settings ?? TalkerSettings();
_logger = logger ??
TalkerLogger().copyWith(
settings: loggerSettings,
filter: loggerFilter,
formater: loggerFormater,
);
if (observers != null && observers.isNotEmpty) {
_observersManager = TalkerObserversManager(observers);
}
_errorHandler = TalkerErrorHandler(_settings);
}

static final _talker = Talker._();
static TalkerInterface get instance => _talker;

/// Fields can be setup in [configure()] method
late TalkerSettings _settings;
late TalkerLoggerInterface _logger;
Expand All @@ -22,14 +58,14 @@ class Talker implements TalkerInterface {

/// {@macro talker_configure}
@override
Future<void> configure({
void configure({
TalkerLogger? logger,
TalkerSettings? settings,
TalkerLoggerSettings? loggerSettings,
TalkerLoggerFilter? loggerFilter,
LoggerFormater? loggerFormater,
List<TalkerObserver>? observers,
}) async {
}) {
if (settings != null) {
_settings = settings;
}
Expand Down Expand Up @@ -232,6 +268,18 @@ class Talker implements TalkerInterface {
}
}

///{@macro talker_disable}
@override
void disable() {
_settings.enabled = false;
}

///{@macro talker_enable}
@override
void enable() {
_settings.enabled = true;
}

void _handleLog(
String message,
Object? exception,
Expand Down Expand Up @@ -302,16 +350,4 @@ class Talker implements TalkerInterface {
_history.add(data);
}
}

///{@macro talker_disable}
@override
void disable() {
_settings.enabled = false;
}

///{@macro talker_enable}
@override
void enable() {
_settings.enabled = true;
}
}
Loading

0 comments on commit 21d6195

Please sign in to comment.