PHP Classes

File: src/Logger.php

Recommend this page to a friend!
  Classes of Thierry Feuzeu   Jaxon for CakePHP   src/Logger.php   Download  
File: src/Logger.php
Role: Class source
Content type: text/plain
Description: Class source
Class: Jaxon for CakePHP
This package integrates the Jaxon library into the
Author: By
Last change:
Date: 3 years ago
Size: 1,530 bytes
 

Contents

Class file image Download
<?php

namespace Jaxon\Cake;

use
Psr\Log\LoggerInterface;
use
Psr\Log\AbstractLogger;
use
Psr\Log\LogLevel;
use
Psr\Log\InvalidArgumentException;

use
Cake\Log\Log as CakeLogger;

class
Logger extends AbstractLogger implements LoggerInterface
{
    public function
log($sLevel, $sMessage, array $aContext = [])
    {
       
$sMessage = rtrim((string)$sMessage, ' .') . '. ' . print_r($aContext, true);

       
// Map the PSR-3 severity to CodeIgniter log level.
       
switch($sLevel)
        {
            case
LogLevel::EMERGENCY:
               
CakeLogger::write('emergency', $sMessage);
                break;
            case
LogLevel::ALERT:
               
CakeLogger::write('alert', $sMessage);
                break;
            case
LogLevel::CRITICAL:
               
CakeLogger::write('critical', $sMessage);
                break;
            case
LogLevel::ERROR:
               
CakeLogger::write('error', $sMessage);
                break;
            case
LogLevel::WARNING:
               
CakeLogger::write('warning', $sMessage);
                break;
            case
LogLevel::DEBUG:
               
CakeLogger::write('debug', $sMessage);
                break;
            case
LogLevel::NOTICE:
               
CakeLogger::write('notice', $sMessage);
                break;
            case
LogLevel::INFO:
               
CakeLogger::write('info', $sMessage);
                break;
            default:
                throw new
InvalidArgumentException("Unknown severity level");
        }
    }
}