Keep Tokenview and Telegram running when log files are not writable.
Daily logs created by root cron were blocking www from appending, which aborted webhook ingest and bot pushes. File channels now use 0664 plus exception-safe stacks, and writes go through SafeLog. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -3,10 +3,10 @@
|
||||
namespace App\Http\Controllers\Hooks;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Support\SafeLog;
|
||||
use App\Telegram\TelegramBotContext;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use SergiX44\Nutgram\Nutgram;
|
||||
use Throwable;
|
||||
|
||||
@@ -81,10 +81,6 @@ class TelegramWebhookController extends Controller
|
||||
/** @param array<string, mixed> $context */
|
||||
private function webhookLog(string $level, string $message, array $context = []): void
|
||||
{
|
||||
try {
|
||||
Log::channel('telegram')->{$level}($message, $context);
|
||||
} catch (Throwable) {
|
||||
error_log($message.' '.json_encode($context, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
SafeLog::channel('telegram')->{$level}($message, $context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ namespace App\Http\Controllers\Hooks;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Tokenview\TokenviewMonitorService;
|
||||
use App\Support\SafeLog;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Throwable;
|
||||
|
||||
class TokenviewWebhookController extends Controller
|
||||
@@ -73,14 +73,10 @@ class TokenviewWebhookController extends Controller
|
||||
/** @param array<string, mixed> $context */
|
||||
private function tvLog(string $level, string $message, array $context = []): void
|
||||
{
|
||||
try {
|
||||
$dir = storage_path('logs/tokenview');
|
||||
if (! is_dir($dir)) {
|
||||
@mkdir($dir, 0775, true);
|
||||
}
|
||||
Log::channel('tokenview')->{$level}($message, $context);
|
||||
} catch (Throwable $e) {
|
||||
Log::warning($message, $context + ['tokenview_channel_error' => $e->getMessage()]);
|
||||
$dir = storage_path('logs/tokenview');
|
||||
if (! is_dir($dir)) {
|
||||
@mkdir($dir, 0775, true);
|
||||
}
|
||||
SafeLog::channel('tokenview')->{$level}($message, $context);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user