<?php namespace App\Services;

use App\Services\ServiceResponse\ServiceResponse;
use App\Services\ServiceResponse\ServiceResponseInterface;
use App\Utils\ResponseException;
use Config\Services;
use Exception;

class LogService extends Service
{
    public function log_error(int $error_code, string $message, array $data) : void
    {
        $json_data = json_encode($data);
        log_message('error', "Erro $error_code. $message. data: $json_data");
    }

    public function log_response_exception(ResponseException $exception) : void
    {
        $this->log_error(
            $exception->getCode() ?? 0,
            $exception->getMessage() ?? '',
            $exception->getData() ?? []
        );
    }
}