TalkerDioLogger configuration and security guide for HTTP request/response logging.
HttpModule Interceptor Order#
package/openapi_service/lib/src/http/http_module.dartof the Interceptor chain:
| Order | Interceptor | Role |
| 1 | DioCacheInterceptor | Response caching (HiveStore/MemStore) |
| 2 | Setting interceptors | Custom setting interceptors |
| 3 | AuthInterceptor | Auth token injection |
| 4 | RateLimitInterceptor | Request rate limiting |
| 5 | TalkerDioLogger | HTTP Logging (Debug mode only) |
| 6 | RetryInterceptor | Retry on failure |
TalkerDioLogger Configuration#
Default Configuration#
import 'package:flutter/foundation.dart' show kDebugMode;
import 'package:talker_dio_logger/talker_dio_logger.dart';
// Enabled only in debug mode
if (kDebugMode) {
dio.interceptors.add(
TalkerDioLogger(
settings: const TalkerDioLoggerSettings(
printRequestHeaders: true,
printResponseHeaders: true,
),
),
);
}
Configuration Options#
| Option | Default | Description |
printRequestHeaders | false | Print request headers |
printResponseHeaders | false | Print response headers |
printResponseMessage | true | Print response message |
printRequestData | true | Print request body |
printResponseData | true | Print response body |
Extended Configuration (if needed)#
TalkerDioLogger(
settings: TalkerDioLoggerSettings(
printRequestHeaders: true,
printResponseHeaders: true,
// ์๋ฌ๋ง ์ถ๋ ฅ
printErrorData: true,
printErrorHeaders: true,
printErrorMessage: true,
// Request/response data filtering
requestFilter: (options) => !options.path.contains('/health'),
responseFilter: (response) => response.statusCode != 200,
),
)
Security Rules#
// โ Prohibited: Including sensitive info in logs
Log.d('๐ ๋ก๊ทธ์ธ: userId=$userId, password=$password');
Log.d('๐ ํ ํฐ: accessToken=$accessToken');
// โ
๊ถ์ฅ: ์ํ๋ง ๊ธฐ๋ก
Log.d('๐ ๋ก๊ทธ์ธ API ํธ์ถ');
Log.d('๐ ํ ํฐ ๊ฐฑ์ ์๋ฃ');
| Type | Example | Logging |
| Credentials | password, pin, userPw | โ Prohibited |
| Tokens | accessToken, refreshToken, idToken | โ Prohibited |
| Identification | userId, loginId (except debugging) | โ ๏ธ Caution |
| Personal Info | phoneNumber, email, address | โ Prohibited |
| Auth Codes | smsCode, verificationCode | โ Prohibited |
kDebugMode Pattern#
Correct Usage#
import 'package:flutter/foundation.dart' show kDebugMode;
// โ
Compile-time constant, removed from production code
if (kDebugMode) {
// Debug-only code
}
Precautions#
// โ ๊ธ์ง: Runtime check (code included in production)
final isDebug = !const bool.fromEnvironment('dart.vm.product');
if (isDebug) { ... }
// โ
๊ถ์ฅ: kDebugMode ์ฌ์ฉ
if (kDebugMode) { ... }
Checklist#
When Adding a Logger#
During PR Review#
Logging Style for Mapper and Repository Mixin#
Log Message Hierarchy#
| Layer | Pattern | Example |
| Mapper |
Structured logging only |
Log.e('msg', error: e, stackTrace: st) |
| Repository start |
Fixed message |
Log.d('๐ API Call') |
| Repository Success |
Including result |
Log.d('โ
Complete: ${count}๊ฐ') |
| Repository Error |
Structured logging |
Log.e('msg', error: e, stackTrace: st) |
Structured Logging Pattern (Required)#
// โ
CORRECT: error ํ๋ผ๋ฏธํฐ ํฌํจ
Log.e('โ Homework API Error', error: error, stackTrace: stackTrace);
// โ WRONG: error ํ๋ผ๋ฏธํฐ ๋๋ฝ
Log.e('โ Homework API Error: $error');
Log.e('โ Homework API Error');
// โ WRONG: stackTrace ๋๋ฝ
Log.e('โ Homework API Error', error: error);
Reason#
- Consistency: All error logging follows the same structure
-
Parsing: Log aggregation tools (Stack Driver, etc.) can parse
error field
- Information preservation: stackTrace stored as structured field