Recommend this page to a friend! |
Download .zip |
Info | Documentation | View files (12) | Download .zip | Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2021-05-11 (4 months ago) | Not yet rated by the users | Total: 20 | All time: 10,354 This week: 259 |
Version | License | PHP version | Categories | |||
queasy-log 1.0 | Custom (specified... | 5 | PHP 5, Logging, PSR |
Description | Author | |
This package can log messages to containers compliant with PSR-3. |
v-dem/queasy-log
Contains logger classes compatible with PSR-3 logger interface. Currently file system and console loggers are implemented. This package includes these types of logging:
See our Wiki page.
composer require v-dem/queasy-log:master-dev
Let's imagine we have the following config.php
:
return [
'logger' => [
'class' => queasy\log\FileSystemLogger::class, // Logger class
'processName' => 'test', // Process name, to differentiate log messages from different sources
'minLevel' => Psr\Log\LogLevel::WARNING, // Message's minimum acceptable log level
'path' => 'debug.log' // Path to logger output file
]
];
Include Composer autoloader:
require_once('vendor/autoload.php');
Create config instance (using v-dem/queasy-config
package):
$config = new queasy\config\Config('config.php');
Or using arrays:
$config = include('config.php');
Create logger instance (in this case class
option can be omitted and will be ignored):
$logger = new queasy\log\Logger($config);
Another way to create logger instance (it will create an instance of $config->logger->class
, by default queasy\log\Logger
as an aggregate logger will be used):
$logger = queasy\log\Logger::create($config);
> FileSystemLogger
and ConsoleLogger
have default settings and can be used without config. Default log file path for
> FileSystemLogger
is debug.log
, default min log level is Psr\Log\LogLevel::DEBUG
and max is LogLevel::EMERGENCY
.
Output warning message:
$logger->warning('Test warning message.');
In debug.log
you'll see something like this:
2017-12-24 16:13:09.302334 EET test [] [] [WARNING] Test warning message.
$logger
->warning('going strange')
->error('cannot connect to the database')
->emergency('the website is down');
config.php
:
return [
[
'class' => queasy\log\FileSystemLogger::class,
'path' => 'debug.full.log',
'minLevel' => Psr\Log\LogLevel::DEBUG,
[
'class' => queasy\log\ConsoleLogger::class,
'minLevel' => Psr\Log\LogLevel::INFO
], [
'class' => queasy\log\SimpleMailLogger::class,
'minLevel' => Psr\Log\LogLevel::ALERT,
'mailTo' => 'john.doe@example.com',
'subject' => 'Website Alert'
]
], [
'class' => queasy\log\FileSystemLogger::class,
'path' => 'debug.log',
'minLevel' => Psr\Log\LogLevel::INFO
]
];
Usage:
$config = new queasy\config\Config('config.php');
$logger = new queasy\log\Logger($config);
$logger->info('Hello, world!');
timeLabel
)config.php
:
return [
[
'class' => queasy\log\FileSystemLogger::class,
'path' => 'debug-full.%s.log',
'timeLabel' => 'Y-m-d',
'minLevel' => Psr\Log\LogLevel::DEBUG
]
];
Files |
File | Role | Description | ||
---|---|---|---|---|
src (5 files) | ||||
tests (1 directory) | ||||
.travis.yml | Data | Auxiliary data | ||
codecov.yml | Data | Auxiliary data | ||
composer.json | Data | Auxiliary data | ||
LICENSE | Lic. | License text | ||
phpunit.xml | Data | Auxiliary data | ||
README.md | Doc. | Documentation |
Files | / | src |
File | Role | Description |
---|---|---|
ConsoleLogger.php | Class | Class source |
FileSystemLogger.php | Class | Class source |
InvalidArgumentException.php | Class | Class source |
Logger.php | Class | Class source |
SimpleMailLogger.php | Class | Class source |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.