Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
230c638
:construction: initial refactor
techouse May 3, 2025
a406819
:construction: update SDK and dependency versions in pubspec.yaml
techouse May 3, 2025
d87e168
:construction: add more settings
techouse May 3, 2025
38b2f33
:construction: add more settings
techouse May 3, 2025
8dc5943
:construction: wip
techouse May 3, 2025
e0b30f9
:construction: wip
techouse May 3, 2025
8e7ed8b
:construction: wip
techouse May 3, 2025
6e3a263
:construction: wip
techouse May 3, 2025
7a4185b
:construction: wip
techouse May 3, 2025
7c869ff
:construction: wip
techouse May 3, 2025
fbdef97
:speech_balloon: update workflow name for consistency
techouse May 3, 2025
c76fca6
Merge branch 'master' into feat/http-logger-v1.0.0
techouse May 3, 2025
70e177a
:construction: wip
techouse May 3, 2025
cb5615e
:construction: wip
techouse May 4, 2025
53543f8
:white_check_mark: increase test coverage
techouse May 5, 2025
5f74d76
:white_check_mark: increase test coverage
techouse May 5, 2025
5059add
:white_check_mark: increase test coverage
techouse May 5, 2025
c4d7823
:white_check_mark: increase test coverage
techouse May 5, 2025
a009ae0
:white_check_mark: increase test coverage
techouse May 5, 2025
9faf52b
:white_check_mark: increase test coverage
techouse May 5, 2025
d3fde75
:technologist: update example
techouse May 5, 2025
899932a
:memo: update changelog
techouse May 5, 2025
9a16d0c
:art: refactor CurlRequest extension to use static JsonEncoder
techouse May 5, 2025
e2d0b13
:memo: update README to enhance example project documentation
techouse May 5, 2025
12c0d1a
:bento: add preview image
techouse May 5, 2025
d1724f1
:memo: update readme
techouse May 5, 2025
439258f
:memo: update readme
techouse May 5, 2025
dff1d52
:rewind: revert dio readme change
techouse May 5, 2025
9576e2e
:memo: update example readme
techouse May 5, 2025
c0015b1
:memo: fix docs
techouse May 5, 2025
4835530
Update packages/talker_http_logger/README.md
techouse May 5, 2025
eb2cd34
Merge branch 'master' into feat/http-logger-v1.0.0
techouse May 16, 2025
cacccef
Merge remote-tracking branch 'origin/master' into feat/http-logger-v1…
techouse May 19, 2025
ed123e4
Merge branch 'master' into feat/http-logger-v1.0.0
techouse May 21, 2025
c3d19c9
Merge branch 'master' into feat/http-logger-v1.0.0
techouse May 25, 2025
f26d121
Merge branch 'master' into feat/http-logger-v1.0.0
techouse Jun 5, 2025
724795d
Merge branch 'master' into feat/http-logger-v1.0.0
techouse Jun 10, 2025
3ffb8f8
Merge branch 'master' into feat/http-logger-v1.0.0
Frezyx Jun 13, 2025
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
20 changes: 20 additions & 0 deletions .github/workflows/talker_http_logger.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: talker_http_logger

on:
push:
paths:
- "packages/talker_http_logger/**"
- ".github/workflows/talker_http_logger.yaml"
pull_request:
paths:
- "packages/talker_http_logger/**"
- ".github/workflows/talker_http_logger.yaml"
permissions:
contents: read

jobs:
test:
uses: ./.github/workflows/test.yaml
with:
package: talker_http_logger
sdk: dart
Binary file added docs/assets/talker_http_logger/preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions packages/talker_http_logger/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 1.0.0
- Complete overhaul of the package

Thanks to [techouse](https://github.com/techouse)

# 0.1.0-dev.55
- [talker_riverpod_logger] add family arguments to the logs

Expand All @@ -6,8 +11,6 @@ Thanks to [lucavenir](https://github.com/lucavenir)
# 0.1.0-dev.54
- [talker_riverpod_logger] add an error filter

Thanks to [lucavenir](https://github.com/lucavenir)

# 0.1.0-dev.53
- [talker] Add `CustomLog` Documentation
- [example] Update plugin com.android.application to v8.10.1
Expand Down
61 changes: 61 additions & 0 deletions packages/talker_http_logger/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Makefile

help:
@printf "%-20s %s\n" "Target" "Description"
@printf "%-20s %s\n" "------" "-----------"
@make -pqR : 2>/dev/null \
| awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' \
| sort \
| egrep -v -e '^[^[:alnum:]]' -e '^$@$$' \
| xargs -I _ sh -c 'printf "%-20s " _; make _ -nB | (grep -i "^# Help:" || echo "") | tail -1 | sed "s/^# Help: //g"'

analyze:
@# Help: Analyze the project's Dart code.
dart analyze --fatal-infos

check_format:
@# Help: Check the formatting of one or more Dart files.
dart format --output=none --set-exit-if-changed .

check_outdated:
@# Help: Check which of the project's packages are outdated.
dart pub outdated

check_style:
@# Help: Analyze the project's Dart code and check the formatting one or more Dart files.
make analyze && make check_format

code_gen:
@# Help: Run the build system for Dart code generation and modular compilation.
dart run build_runner build --delete-conflicting-outputs

code_gen_watcher:
@# Help: Run the build system for Dart code generation and modular compilation as a watcher.
dart run build_runner watch --delete-conflicting-outputs

format:
@# Help: Format one or more Dart files.
dart format .

install:
@# Help: Install all the project's packages
dart pub get

sure:
@# Help: Analyze the project's Dart code, check the formatting one or more Dart files and run unit tests for the current project.
make check_style && make tests

show_test_coverage:
@# Help: Run Dart unit tests for the current project and show the coverage.
dart pub global activate coverage && dart pub global run coverage:test_with_coverage
lcov --remove coverage/lcov.info '**.g.dart' '**.mock.dart' -o coverage/lcov_without_generated_code.info --ignore-errors unused
genhtml coverage/lcov_without_generated_code.info -o coverage/html
source tool/makefile_helpers.sh && open_link "coverage/html/index.html"

tests:
@# Help: Run Dart unit and widget tests for the current project.
dart test

upgrade:
@# Help: Upgrade all the project's packages.
dart pub upgrade
105 changes: 95 additions & 10 deletions packages/talker_http_logger/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# talker_http_logger
Lightweight and customizable [http](https://pub.dev/packages/http) client logger on [talker](https://pub.dev/packages/talker) base.<br>
Lightweight and customizable [http_interceptor](https://pub.dev/packages/http_interceptor) client logger on [talker](https://pub.dev/packages/talker) base.<br>
[Talker](https://github.com/Frezyx/talker) - Advanced exception handling and logging for dart/flutter applications 🚀

<p>
Expand All @@ -15,27 +15,33 @@ Lightweight and customizable [http](https://pub.dev/packages/http) client logger

## Preview
This is how the logs of your http requests will look in the console
![](https://github.com/Frezyx/talker/blob/dev/docs/assets/talker_http_logger/preview.png?raw=true)
![](/docs/assets/talker_http_logger/preview.png?raw=true)

## Getting started
Follow these steps to use this package

### Add dependency
```yaml
dependencies:
talker_http_logger: ^0.1.0-dev.55
talker_http_logger: ^1.0.0
```

### Usage
Just add **TalkerHttpLogger** to your **InterceptedClient** instance and it will work
Just add **TalkerHttpLogger** to your [**InterceptedClient**](https://pub.dev/packages/http_interceptor) instance and it will work

```dart
import 'package:http_interceptor/http_interceptor.dart';
import 'package:talker_http_logger/talker_http_logger.dart';

void main() async {
final client = InterceptedClient.build(interceptors: [
TalkerHttpLogger(),
TalkerHttpLogger(
settings: const TalkerHttpLoggerSettings(
printRequestHeaders: true,
printResponseHeaders: true,
printResponseMessage: true,
),
),
]);

await client.get("https://google.com".toUri());
Expand All @@ -52,13 +58,92 @@ import 'package:http_interceptor/http_interceptor.dart';
import 'package:talker_http_logger/talker_http_logger.dart';

void main() async {
final talker = Talker();
final client = InterceptedClient.build(interceptors: [
TalkerHttpLogger(talker: talker),
]);
final _talker = Talker();
final client = InterceptedClient.build(
/// ... other settings
interceptors: [
TalkerHttpLogger(
/// ... other Talker HTTP Logger settings
talker: _talker,
),
]
);

await client.get("https://google.com".toUri());
}
```

### Print HTTP request curl command

You can print the curl command for the HTTP request in the console.
This is useful for debugging and testing purposes.

```dart
final client = InterceptedClient.build(
/// ... other settings
interceptors: [
TalkerHttpLogger(
talker: _talker,
settings: const TalkerHttpLoggerSettings(
// Print curl command for HTTP request
printRequestCurl: true,
),
),
],
);
```

### Hiding sensitive HTTP request headers

You can hide sensitive HTTP request headers such as `Authorization` or `Cookie` in the console logs.
This is useful for security purposes.

```dart
final client = InterceptedClient(
/// ... other settings
interceptors: [
TalkerHttpLogger(
talker: _talker,
settings: const TalkerHttpLoggerSettings(
printRequestHeaders: true,
printResponseHeaders: true,
// Hide sensitive HTTP request headers
hiddenHeaders: {
'authorization',
'cookie',
},
),
),
],
);
```

### Change HTTP logs colors

Customize your HTTP log colors by defining specific colors for requests, responses, and errors in
[TalkerHttpLoggerSettings](lib/talker_http_logger_settings.dart)

```dart
TalkerHttpLoggerSettings(
// Blue HTTP requests logs in console
requestPen: AnsiPen()..blue(),
// Green HTTP responses logs in console
responsePen: AnsiPen()..green(),
// Error HTTP logs in console
errorPen: AnsiPen()..red(),
);
```

### Filter HTTP logs

For instance, if your app includes private functionality that you prefer not to log with talker, you can apply filters.

```dart
TalkerHttpLoggerSettings(
// All http requests without "/secure" in path will be printed in console
requestFilter: (Request request) => !request.url.path.contains('/secure'),
// All http responses with status codes different than 301 will be printed in console
responseFilter: (Response response) => response.statusCode != 301,
)
```

## Additional information
Expand Down
46 changes: 46 additions & 0 deletions packages/talker_http_logger/example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.build/
.buildlog/
.history
.svn/
.swiftpm/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.pub-cache/
.pub/
/build/
pubspec.lock

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
36 changes: 36 additions & 0 deletions packages/talker_http_logger/example/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: "ea121f8859e4b13e47a8f845e4586164519588bc"
channel: "stable"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: ea121f8859e4b13e47a8f845e4586164519588bc
base_revision: ea121f8859e4b13e47a8f845e4586164519588bc
- platform: android
create_revision: ea121f8859e4b13e47a8f845e4586164519588bc
base_revision: ea121f8859e4b13e47a8f845e4586164519588bc
- platform: ios
create_revision: ea121f8859e4b13e47a8f845e4586164519588bc
base_revision: ea121f8859e4b13e47a8f845e4586164519588bc
- platform: web
create_revision: ea121f8859e4b13e47a8f845e4586164519588bc
base_revision: ea121f8859e4b13e47a8f845e4586164519588bc

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
34 changes: 34 additions & 0 deletions packages/talker_http_logger/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Example Project

This example demonstrates the usage of the talker_http_logger package for logging HTTP requests, responses, and
errors.

## Setup

Install dependencies:

```shell
flutter pub get
```

## Running the Example

To run the example application:

```shell
flutter run
```

## Directory Structure

Within the example directory you will typically find:

- A main entry point that demonstrates the logging functionality.
- Supporting files or configurations that illustrate how logging is customized using the package's settings.

## Customization

- Adjust logging settings directly within the example code to explore options such as:
- Printing request headers and data.
- Displaying cURL commands to replicate HTTP requests.
- Customizing the output format of errors, responses, and request logs.
11 changes: 11 additions & 0 deletions packages/talker_http_logger/example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
analyzer:
exclude:
- "lib/generated_plugin_registrant.dart"
- "**.mocks.dart"
- "**.gen.dart"

include: package:flutter_lints/flutter.yaml

linter:
rules:
- require_trailing_commas
14 changes: 14 additions & 0 deletions packages/talker_http_logger/example/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
gradle-wrapper.jar
/.gradle
/captures/
/gradlew
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java
.cxx/

# Remember to never publicly share your keystore.
# See https://flutter.dev/to/reference-keystore
key.properties
**/*.keystore
**/*.jks
Loading