PHP Classes

File: src/Logger.php

Recommend this page to a friend!
  Classes of Thierry Feuzeu   Jaxon for Yii   src/Logger.php   Download  
File: src/Logger.php
Role: Class source
Content type: text/plain
Description: Class source
Class: Jaxon for Yii
Yi plugin to call PHP from with AJAX
Author: By
Last change:
Date: 3 years ago
Size: 1,131 bytes
 

Contents

Class file image Download
<?php

namespace Jaxon\Yii;

use
Yii;

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

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

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