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

Delay setting the handler in Logger so each Logger can have its own handler #50

Merged
merged 1 commit into from
Nov 2, 2023

Conversation

lux
Copy link
Collaborator

@lux lux commented Oct 25, 2023

Each Logger instance stores its handler and switches the handler used by Analog before logging, which I think might solve #49 with minimal changes.

Example usage:

<?php

require 'vendor/autoload.php';

use Analog\Logger;
use Analog\Handler;

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

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

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

$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->debug ('Log 2.3');

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

@lux lux merged commit c0e16a9 into master Nov 2, 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