czproject/logger

Output logger.

v0.11.0 2018-12-16 18:27 UTC

README

Become a Patron! Buy me a coffee

Installation

Download a latest package or use Composer:

composer require czproject/logger

CzProject\Logger requires PHP 5.4.0 or later.

Usage

use CzProject\Logger;
use CzProject\Logger\ILogger;

$logger = new Logger\OutputLogger(ILogger::DEBUG); // minimal level
$logger->log('Debug info', ILogger::DEBUG);
$logger->log('Output', ILogger::INFO);
$logger->log('Done!', ILogger::SUCCESS);
$logger->log('Warning...', ILogger::WARNING);
$logger->log('Error message', ILogger::ERROR);
$logger->log('Exception message', ILogger::EXCEPTION);
$logger->log('App crashed.', ILogger::CRITICAL);

Loggers

  • CzProject\Logger\CliLogger($level, $colored = NULL) - sends messages to CLI STDOUT
  • CzProject\Logger\OutputLogger($level) - prints messages to STDOUT
  • CzProject\Logger\FileLogger($path, $level) - saves messages into new created file
  • CzProject\Logger\MultiLogger() - sends messages to other loggers
$logger = new Logger\MultiLogger;
$logger->addLogger(new Logger\OutputLogger(ILogger::INFO));
$logger->addLogger(new Logger\FileLogger(__DIR__ . '/debug.log', ILogger::DEBUG));

$logger->log($msg, $level);

License: New BSD License
Author: Jan Pecha, https://www.janpecha.cz/