-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add PSR/Log as dependency - Add a new SimpleLogger - Use the NullLogger per default Helps with #461 Signed-off-by: Daniel Ziegenberg <daniel@ziegenberg.at>
- Loading branch information
1 parent
3163c9f
commit 4174b83
Showing
11 changed files
with
133 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace Sabberworm\CSS; | ||
|
||
use Psr\Log\AbstractLogger; | ||
|
||
/** | ||
* This class provides a simple logging facility. | ||
*/ | ||
class SimpleLogger extends AbstractLogger | ||
{ | ||
|
||
public function log($level, $message, array $context = []): void | ||
{ | ||
echo self::interpolate($message, $context) . PHP_EOL; | ||
} | ||
|
||
/** | ||
* Interpolates context values into the message placeholders. | ||
*/ | ||
private function interpolate(string $message, array $context = []): string | ||
{ | ||
// build a replacement array with braces around the context keys | ||
$replace = []; | ||
foreach ($context as $key => $val) { | ||
// check that the value can be cast to string | ||
if (!is_array($val) && (!is_object($val) || method_exists($val, '__toString'))) { | ||
$replace['{' . $key . '}'] = $val; | ||
} | ||
} | ||
|
||
// interpolate replacement values into the message and return | ||
return strtr($message, $replace); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters