strata-mvc/strata

View on GitHub
src/Error/ErrorLogger.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace Strata\Error;

use Strata\Strata;
use Exception;

/**
 * The object that helps representing the errors visually in the logs.
 */
class ErrorLogger
{
    public function logError(array $error)
    {
        $this->logMessage(sprintf(
            '%s (%s): %s in [%s, line %s]',
            $error['type'],
            $error['code'],
            $error['description'],
            $error['file'],
            $error['line']
        ));
    }

    private function logMessage($message = "")
    {
        $logger = Strata::app()->getLogger();
        if (!is_null($logger)) {
            $logger->error($message, "Strata:Error");
        }
    }
}