Skip to content
This repository was archived by the owner on Jan 11, 2018. It is now read-only.

Commit 63b6d3f

Browse files
authored
Add pushHandler to interface (#3)
This allows implementations to use pushHandler, which is useful for changing where something can log. For example, this is useful if you want to suppress errors during tests.
1 parent 8adf889 commit 63b6d3f

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/PaperG/Logger/StaticLoggerWrapper.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22

33
namespace PaperG\Logger;
4+
use Monolog\Handler\StreamHandler;
5+
use Monolog\Logger;
46
use Psr\Log\LoggerInterface;
57
use InvalidArgumentException;
68

@@ -250,4 +252,16 @@ public static function debug($message, $context = null, $tags = [])
250252
$contextExists = func_num_args() >= 2; // Distinguish debug($m, null) vs. debug($m)
251253
static::getLogger()->debug($message, self::makeContextArray($context, $contextExists, $tags));
252254
}
255+
256+
/**
257+
* Allows specific implementations to use different handlers
258+
*
259+
* @param $streamHandler StreamHandler
260+
*/
261+
public static function pushHandler($streamHandler)
262+
{
263+
/* @var $monologLogger Logger */
264+
$monologLogger = static::getLogger();
265+
$monologLogger->pushHandler($streamHandler);
266+
}
253267
}

0 commit comments

Comments
 (0)