1
0
forked from baron/baron-sso

userfront gateway 분리.

This commit is contained in:
Lectom C Han
2026-01-30 16:14:20 +09:00
parent 35552943d7
commit 1db7ce8f10
8 changed files with 302 additions and 99 deletions

View File

@@ -469,6 +469,9 @@ class AuthProxyService {
}
static Future<void> sendLog(String level, String message, {Map<String, dynamic>? data}) async {
if (!_canSendClientLog()) {
return;
}
final url = Uri.parse('$_baseUrl/api/v1/client-log');
try {
await http.post(
@@ -480,7 +483,9 @@ class AuthProxyService {
if (data != null) 'data': data,
}),
);
_recordClientLogSuccess();
} catch (_) {
_recordClientLogFailure();
// Ignore logging errors to prevent loops
}
}
@@ -493,6 +498,34 @@ class AuthProxyService {
await sendLog('ERROR', message, data: data);
}
static int _clientLogFailureCount = 0;
static DateTime? _clientLogLastFailureAt;
static DateTime? _clientLogOpenUntil;
static bool _canSendClientLog() {
final now = DateTime.now();
final openUntil = _clientLogOpenUntil;
if (openUntil != null && now.isBefore(openUntil)) {
return false;
}
return true;
}
static void _recordClientLogFailure() {
_clientLogFailureCount += 1;
_clientLogLastFailureAt = DateTime.now();
if (_clientLogFailureCount >= 3) {
_clientLogOpenUntil = DateTime.now().add(const Duration(minutes: 1));
_clientLogFailureCount = 0;
}
}
static void _recordClientLogSuccess() {
_clientLogFailureCount = 0;
_clientLogLastFailureAt = null;
_clientLogOpenUntil = null;
}
// --- Signup Methods ---
static Future<bool> checkEmailAvailability(String email) async {

View File

@@ -25,7 +25,7 @@ class LoggerService {
);
// 2. Configure Standard Logger (logging package)
std_log.Logger.root.level = kReleaseMode ? std_log.Level.INFO : std_log.Level.ALL;
std_log.Logger.root.level = kReleaseMode ? std_log.Level.WARNING : std_log.Level.ALL;
std_log.Logger.root.onRecord.listen((record) {
if (kReleaseMode) {
@@ -71,7 +71,7 @@ class LoggerService {
debugPrint(jsonEncode(logData));
// 2. Relay to Backend (Docker Terminal)
if (record.level >= std_log.Level.INFO) {
if (record.level >= std_log.Level.WARNING) {
AuthProxyService.sendLog(
record.level.name,
record.message,