Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes support for nested loggers when using multiple Logger instances #51

Merged
merged 3 commits into from
Dec 10, 2023

Conversation

lux
Copy link
Collaborator

@lux lux commented Dec 9, 2023

This ought to make it possible to support nested loggers with multiple Logger instances, fixing #49.

Usage is slightly different, where now instead of each handler being a static ::init() call, we instantiate the handler via new Handler\LevelBuffer() at the first level and Analog should take care of the rest.

<?php

require 'vendor/autoload.php';

use Analog\Logger;
use Analog\Handler;

$log1 = '';
$log2 = '';

$logger1 = new Logger ();
$logger1->handler (new Analog\Handler\LevelName (
	Handler\Variable::init ($log1)
));

$logger2 = new Logger ();
$logger2->handler (new Analog\Handler\LevelBuffer (
	Handler\Variable::init ($log2),
	Analog::ERROR
));

$logger1->debug ('Log 1.1');
$logger2->debug ('Log 2.1');

$logger1->debug ('Log 1.2');
$logger2->debug ('Log 2.2');

$logger1->debug ('Log 1.3');
$logger2->error ('Log 2.3');

echo $log1;
echo '---' . PHP_EOL;
echo $log2;

@lux lux merged commit 606a21c into master Dec 10, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant