jeudi 3 août 2017

Laravel ERROR logging unexpected output

Below function is used to log an error with details

private function logError($xml, Exception $e, $fromWhere = "")
{
    $log = new Logger('REQUEST_ERROR_LOG');
    $logger = $log->pushHandler(
        new StreamHandler(
            storage_path('logs/error/'.date('Y').'/'.date('m').'/'.date('d') . '.log')
        ),
        Logger::INFO
    );

    $logger->addError('', [
        array(
            "FILE"    => $e->getFile(),
            "LINE"    => $e->getLine(),
            "MESSAGE" => $e->getMessage(),
            "FROM"    => $fromWhere,
            "XML"     => $xml
        )
    ]);
}

This is how i call it

private function addUser($xml)
{
    try {
        $xmlObj = simplexml_load_string($xml);
    } catch (Exception $e) {
        //Exception happens when xml parse error.
        $this->logError($xml, $e, "addUser()");
    }
}

This is the logged details Note that there are no details logged

[2017-08-03 12:45:55] REQUEST_ERROR_LOG.ERROR:   []
[2017-08-03 12:47:22] REQUEST_ERROR_LOG.ERROR:   []
[2017-08-03 12:48:42] REQUEST_ERROR_LOG.ERROR:   []
[2017-08-03 12:49:08] REQUEST_ERROR_LOG.ERROR:   []
[2017-08-03 12:50:28] REQUEST_ERROR_LOG.ERROR:   []

Is there someone who got in to this or any guesses why is this happening?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire