<?php

namespace App\Services\Storage;

class StorageLogger
{
    /**
     * @param 'SUCCESS'|'FAILURE'|'WARNING'|string $status
     * @param array<string, mixed> $context
     */
    public static function log(string $status, string $message, array $context = []): void
    {
        $status = strtoupper($status);

        if (! in_array($status, ['SUCCESS', 'FAILURE', 'WARNING'], true)) {
            $status = 'FAILURE';
        }

        $json = $context !== [] ? ' | ' . json_encode($context, JSON_UNESCAPED_SLASHES) : '';

        log_message('error', "[S3_STORAGE][{$status}] {$message}{$json}");
    }
}
