PHP Classes

File: src/Logger.php

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

Contents

Class file image Download
<?php

namespace Jaxon\CI;

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, ' .') . '. ' . 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:
               
log_message("error", $sMessage);
                break;
            case
LogLevel::WARNING:
            case
LogLevel::DEBUG:
               
log_message("debug", $sMessage);
                break;
            case
LogLevel::NOTICE:
            case
LogLevel::INFO:
               
log_message("info", $sMessage);
                break;
            default:
                throw new
InvalidArgumentException("Unknown severity level");
        }
    }
}