czproject / logger
Output logger.
Fund package maintenance!
Other
Installs: 2 219
Dependents: 3
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=5.6.0
Requires (Dev)
- nette/tester: ^2.0
This package is auto-updated.
Last update: 2024-11-13 19:56:07 UTC
README
Installation
Download a latest package or use Composer:
composer require czproject/logger
CzProject\Logger requires PHP 5.6.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 STDOUTCzProject\Logger\OutputLogger($level)
- prints messages to STDOUTCzProject\Logger\FileLogger($path, $level)
- saves messages into new created fileCzProject\Logger\MemoryLogger($level)
- saves messages into memory, you can use$memoryLogger->getLog()
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);
LoggerProxy
LoggerProxy is interface for using of Logger.
$logger = new Logger\OutputLogger(ILogger::DEBUG); // minimal level $proxy = new Logger\LoggerProxy($logger); $proxy->debug('Debug info'); $proxy->log('Output'); // or $proxy->info() $proxy->success('Done!'); $proxy->warning('Warning...', ILogger::WARNING); $proxy->error('Error message', ILogger::ERROR); $proxy->exception('Exception message', ILogger::EXCEPTION); $proxy->critical('App crashed.', ILogger::CRITICAL);
License: New BSD License
Author: Jan Pecha, https://www.janpecha.cz/