krubio / perfect-logger
A PSR-3 compliant logging library
v0.1.0
2023-08-04 03:39 UTC
Requires
- php: >=8.0
- psr/log: ^3.0
Requires (Dev)
- codeception/codeception: ^5.0
- codeception/module-asserts: *
- phpstan/phpstan: ^1.10
This package is auto-updated.
Last update: 2024-11-04 06:15:25 UTC
README
Perfect Logger
Perfect Logger is a PSR-3 compliant logging library for PHP. It provides an easy way to log messages to a file.
Installation
Install via composer:
composer require krubio/perfect-logger
Usage
<?php require 'vendor/autoload.php'; use PerfectApp\Logger\FileLogger; // Initialize the logger $logger = new FileLogger('/path/to/your/logfile.log'); // Log some messages $logger->emergency('This is an emergency message'); $logger->alert('This is an alert message'); $logger->critical('This is a critical message'); $logger->error('An error occurred', ['errorCode' => 123]); $logger->warning('This is a warning message'); $logger->notice('This is a notice message'); $logger->info('This is an informational message'); $logger->debug('This is a debug message'); $logger->error('An error occurred', [ 'user_id' => 10, 'url' => 'https://example.com', 'data' => 'Important Data' ]);
Log Levels
The logger supports the following log levels:
- Emergency: system is unusable
- Alert: action must be taken immediately
- Critical: critical conditions
- Error: error conditions
- Warning: warning conditions
- Notice: normal but significant condition
- Info: informational messages
- Debug: debug-level messages
License
The MIT License (MIT). Please see License File for more information.