51336e346a
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>
52 lines
1.4 KiB
PHP
52 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit;
|
|
|
|
use App\Support\SafeLog;
|
|
use Illuminate\Support\Facades\Log;
|
|
use Tests\TestCase;
|
|
use UnexpectedValueException;
|
|
|
|
class SafeLogTest extends TestCase
|
|
{
|
|
public function test_write_does_not_throw_when_channel_is_unwritable(): void
|
|
{
|
|
$dir = $this->forceLogChannelUnwritable('tokenview');
|
|
|
|
try {
|
|
SafeLog::channel('tokenview')->info('safe-log probe', ['k' => 1]);
|
|
SafeLog::channel('tokenview')->warning('safe-log warn');
|
|
} finally {
|
|
$this->restoreWritableLogDir($dir);
|
|
}
|
|
|
|
$this->assertTrue(true);
|
|
}
|
|
|
|
public function test_tokenview_stack_swallows_file_permission_errors(): void
|
|
{
|
|
$dir = $this->forceLogChannelUnwritable('tokenview-file');
|
|
Log::forgetChannel('tokenview');
|
|
|
|
try {
|
|
Log::channel('tokenview')->info('stack should swallow file errors');
|
|
} finally {
|
|
$this->restoreWritableLogDir($dir);
|
|
}
|
|
|
|
$this->assertTrue(true);
|
|
}
|
|
|
|
public function test_unwritable_channel_without_safelog_still_throws(): void
|
|
{
|
|
$dir = $this->forceLogChannelUnwritable('tokenview');
|
|
|
|
try {
|
|
$this->expectException(UnexpectedValueException::class);
|
|
Log::channel('tokenview')->info('should throw');
|
|
} finally {
|
|
$this->restoreWritableLogDir($dir);
|
|
}
|
|
}
|
|
}
|