HTTP Logging Rules
TalkerDioLogger configuration and security guide for HTTP request/response logging.
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:
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#
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('🔄 토큰 갱신 완료');
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#
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
- 프로젝트 루트의
CLAUDE.md(AGENTS.md) - HTTP debugging section