davidecesarano / embryo-logger
Minimalist and fast PSR-3 Stream logger.
1.0.2
2020-11-08 13:29 UTC
Requires
- php: >=7.1
- davidecesarano/embryo-http: dev-master
- psr/log: 1.0.2
Requires (Dev)
- phpstan/phpstan: ^0.12.54
This package is auto-updated.
Last update: 2024-11-08 22:13:54 UTC
README
Minimalist and fast PSR-3 Stream logger.
Requirements
- PHP >= 7.1
- A PSR-7 http message implementation and PSR-17 http factory implementation (ex. Embryo-Http)
Installation
Using Composer:
$ composer require davidecesarano/embryo-logger
Usage
Set log
directory and create logger
object. You can set emergency
, alert
, critical
, error
, warning
, notice
, info
, debug
and log
message.
use Embryo\Log\StreamLogger; $logPath = __DIR__.DIRECTORY_SEPARATOR.'logs'; $logger = new StreamLogger($logPath); $message = "User {username} created"; $context = ['username' => 'bolivar']; // info log $logger->info($message, $context);
This example writes User bolivar created
in the info.log
file.
You may quickly test this using the built-in PHP server going to http://localhost:8000.
$ cd example
$ php -S localhost:8000