PHP Classes

File: src/Generics/Logger/ConsoleLogger.php

Recommend this page to a friend!
  Classes of Maik Greubel   PHP Generics   src/Generics/Logger/ConsoleLogger.php   Download  
File: src/Generics/Logger/ConsoleLogger.php
Role: Class source
Content type: text/plain
Description: Basic console logger
Class: PHP Generics
Framework for accessing streams, sockets and logs
Author: By
Last change: Update of src/Generics/Logger/ConsoleLogger.php
Date: 6 months ago
Size: 838 bytes
 

Contents

Class file image Download
<?php
/**
 * This file is part of the PHP Generics package.
 *
 * @package Generics
 */
namespace Generics\Logger;

use
Psr\Log\LogLevel;

/**
 * This class is a standard reference implementation of the PSR LoggerInterface.
 *
 * It logs everything to console. Depending on level it is written to stdout or stderr.
 *
 * @author Maik Greubel <greubel@nkey.de>
 */
class ConsoleLogger extends BasicLogger
{

    protected function
logImpl($level, $message, array $context = array())
    {
       
$channel = STDOUT;
       
        if (
$level === LogLevel::ALERT || $level === LogLevel::CRITICAL || $level === LogLevel::EMERGENCY || $level === LogLevel::ERROR || $level === LogLevel::WARNING) {
           
$channel = STDERR;
        }
       
       
fwrite($channel, $this->getMessage($level, $message, $context)->read(4096));
    }
}