davidecesarano/embryo-logger

Minimalist and fast PSR-3 Stream logger.

1.0.2 2020-11-08 13:29 UTC

This package is auto-updated.

Last update: 2024-04-08 20:47:48 UTC


README

Minimalist and fast PSR-3 Stream logger.

Requirements

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