1
0
forked from baron/baron-sso

로그 포맷 통일, slog 적용

This commit is contained in:
2026-01-15 14:16:34 +09:00
parent 2aff11bc5d
commit 5dd2c94555
9 changed files with 286 additions and 32 deletions

View File

@@ -9,18 +9,28 @@ import 'package:flutter_web_plugins/url_strategy.dart';
import 'features/auth/presentation/login_screen.dart';
import 'features/dashboard/presentation/dashboard_screen.dart';
import 'core/services/auth_proxy_service.dart';
import 'core/services/logger_service.dart';
import 'package:logging/logging.dart';
final _log = Logger('Main');
void main() async {
WidgetsFlutterBinding.ensureInitialized();
usePathUrlStrategy();
// 0. Initialize Logger
LoggerService.init();
// 1. Global Error Handling
FlutterError.onError = (details) {
FlutterError.presentError(details);
_log.severe("FLUTTER_ERROR", details.exception, details.stack);
// Also send to backend if needed
AuthProxyService.logError("FLUTTER_ERROR: ${details.exception}\n${details.stack}");
};
PlatformDispatcher.instance.onError = (error, stack) {
_log.severe("PLATFORM_ERROR", error, stack);
AuthProxyService.logError("PLATFORM_ERROR: $error\n$stack");
return true;
};
@@ -29,7 +39,7 @@ void main() async {
try {
await dotenv.load(fileName: ".env");
} catch (e) {
debugPrint("Warning: .env file not found.");
_log.warning("Warning: .env file not found.");
}
// Initialize Descope
@@ -40,13 +50,15 @@ void main() async {
try {
await Descope.sessionManager.loadSession();
} catch (e) {
debugPrint("Failed to load session: $e");
_log.warning("Failed to load session: $e");
}
runApp(const ProviderScope(child: BaronSSOApp()));
}
// Router Configuration
final _routerLogger = Logger('Router');
final _router = GoRouter(
initialLocation: '/',
debugLogDiagnostics: true, // Enable diagnostic logs
@@ -54,7 +66,7 @@ final _router = GoRouter(
GoRoute(
path: '/',
builder: (context, state) {
debugPrint("[Router] Navigating to root (LoginScreen)");
_routerLogger.info("Navigating to root (LoginScreen)");
return const LoginScreen();
}
),
@@ -62,14 +74,14 @@ final _router = GoRouter(
path: '/verify/:token',
builder: (context, state) {
final token = state.pathParameters['token'];
debugPrint("[Router] Navigating to /verify with token: $token");
_routerLogger.info("Navigating to /verify with token: $token");
return LoginScreen(verificationToken: token);
},
),
GoRoute(
path: '/dashboard',
builder: (context, state) {
debugPrint("[Router] Navigating to /dashboard");
_routerLogger.info("Navigating to /dashboard");
return const DashboardScreen();
},
),
@@ -80,14 +92,14 @@ final _router = GoRouter(
final path = state.uri.path;
final isLoggingIn = path == '/' || path.startsWith('/verify/');
debugPrint("[Router] Redirect check - Path: $path, IsLoggedIn: $isLoggedIn");
_routerLogger.fine("Redirect check - Path: $path, IsLoggedIn: $isLoggedIn");
if (!isLoggedIn && !isLoggingIn) {
debugPrint("[Router] Not logged in, redirecting to /");
_routerLogger.info("Not logged in, redirecting to /");
return '/';
}
if (isLoggedIn && path == '/') {
debugPrint("[Router] Logged in, redirecting to /dashboard");
_routerLogger.info("Logged in, redirecting to /dashboard");
return '/dashboard';
}