-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from joaojacome/master
Split OneLog in two files, onr for static calls and another one PSR-3 compliant
- Loading branch information
Showing
8 changed files
with
220 additions
and
148 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace KoderHut\OnelogBundle\Helper; | ||
|
||
use KoderHut\OnelogBundle\OneLog; | ||
|
||
/** | ||
* Class OneLogStatic | ||
* | ||
* @author Joao Jacome <969041+joaojacome@users.noreply.github.com> | ||
*/ | ||
class OneLogStatic | ||
{ | ||
/** | ||
* @var OneLog|null | ||
*/ | ||
private static $resolved; | ||
|
||
/** | ||
* OneLogStatic constructor | ||
*/ | ||
private function __construct() | ||
{ | ||
} | ||
|
||
/** | ||
* Sets the OneLog instance | ||
* | ||
* @param OneLog $resolved | ||
*/ | ||
public static function setInstance(OneLog $resolved) | ||
{ | ||
self::$resolved = $resolved; | ||
} | ||
|
||
/** | ||
* Returns the OneLog instance | ||
* | ||
* @return OneLog | ||
*/ | ||
public static function instance(): OneLog | ||
{ | ||
if (self::$resolved) { | ||
return self::$resolved; | ||
} | ||
|
||
throw new \RuntimeException('OneLog is not properly instantiated!'); | ||
} | ||
|
||
/** | ||
* Unsets the instance | ||
*/ | ||
public static function destroy() | ||
{ | ||
self::$resolved = null; | ||
} | ||
|
||
/** | ||
* @example OneLog::debug(<string>'message', <array>context) | ||
* | ||
* @param string $level | ||
* @param mixed ...$params | ||
* | ||
* @return mixed | ||
*/ | ||
public static function __callStatic(string $level, $params) | ||
{ | ||
if (!static::$resolved instanceof OneLog) { | ||
throw new \RuntimeException('Logger is not properly instantiated!'); | ||
} | ||
|
||
return self::$resolved->{$level}(...$params); | ||
} | ||
} |
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,93 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace KoderHut\OnelogBundle; | ||
|
||
/** | ||
* Trait PSRLoggerTrait | ||
* | ||
* @author Joao Jacome <969041+joaojacome@users.noreply.github.com> | ||
*/ | ||
trait PSRLoggerTrait | ||
{ | ||
/** | ||
* @param mixed $message | ||
* @param array $context | ||
*/ | ||
public function emergency($message, array $context = array()) | ||
{ | ||
$this->defaultLogger->emergency($message, $context); | ||
} | ||
|
||
/** | ||
* @param mixed $message | ||
* @param array $context | ||
*/ | ||
public function alert($message, array $context = array()) | ||
{ | ||
$this->defaultLogger->alert($message, $context); | ||
} | ||
|
||
/** | ||
* @param mixed $message | ||
* @param array $context | ||
*/ | ||
public function critical($message, array $context = array()) | ||
{ | ||
$this->defaultLogger->critical($message, $context); | ||
} | ||
|
||
/** | ||
* @param mixed $message | ||
* @param array $context | ||
*/ | ||
public function error($message, array $context = array()) | ||
{ | ||
$this->defaultLogger->error($message, $context); | ||
} | ||
|
||
/** | ||
* @param mixed $message | ||
* @param array $context | ||
*/ | ||
public function warning($message, array $context = array()) | ||
{ | ||
$this->defaultLogger->warning($message, $context); | ||
} | ||
|
||
/** | ||
* @param mixed $message | ||
* @param array $context | ||
*/ | ||
public function notice($message, array $context = array()) | ||
{ | ||
$this->defaultLogger->notice($message, $context); | ||
} | ||
|
||
/** | ||
* @param mixed $message | ||
* @param array $context | ||
*/ | ||
public function info($message, array $context = array()) | ||
{ | ||
$this->defaultLogger->info($message, $context); | ||
} | ||
|
||
/** | ||
* @param mixed $message | ||
* @param array $context | ||
*/ | ||
public function debug($message, array $context = array()) | ||
{ | ||
$this->defaultLogger->debug($message, $context); | ||
} | ||
|
||
/** | ||
* @param mixed $level | ||
* @param mixed $message | ||
* @param array $context | ||
*/ | ||
public function log($level, $message, array $context = array()) | ||
{ | ||
return $this->defaultLogger->log($level, $message, $context); | ||
} | ||
} |
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
Oops, something went wrong.