-
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.
- Loading branch information
Showing
5 changed files
with
249 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
namespace TgLog; | ||
|
||
/** | ||
* A wrapper that fulfills the logger interface. | ||
* @author ralph | ||
* | ||
*/ | ||
class LogWrapper implements Logger { | ||
|
||
/** The single instance of the log wrapper using the Log singleton */ | ||
protected static $instance; | ||
|
||
/** | ||
* Returns the single instance. | ||
* @return LogWrapper - single Log instance | ||
*/ | ||
public static function instance() { | ||
if (self::$instance == null) { | ||
self::$instance = new LogWrapper(Log::instance()); | ||
} | ||
return self::$instance; | ||
} | ||
|
||
/** The underlying log */ | ||
protected $log; | ||
|
||
/** | ||
* Constructor. | ||
* @param Log $log - the underlying logger | ||
*/ | ||
public function __construct(Log $log) { | ||
if ($log == NULL) $log = Log::instance(); | ||
$this->log = $log; | ||
} | ||
|
||
/** | ||
* @see \TgLog\Logger::warn() | ||
*/ | ||
public function warn($s, $object = NULL) { | ||
$this->log->logWarn($s, $object); | ||
} | ||
|
||
/** | ||
* @see \TgLog\Logger::debug() | ||
*/ | ||
public function debug($s, $object = NULL) { | ||
$this->log->logDebug($s, $object); | ||
} | ||
|
||
/** | ||
* @see \TgLog\Logger::error() | ||
*/ | ||
public function error($s, $object = NULL) { | ||
$this->log->logError($s, $object); | ||
} | ||
|
||
/** | ||
* @see \TgLog\Logger::info() | ||
*/ | ||
public function info($s, $object = NULL) { | ||
$this->log->logInfo($s, $object); | ||
} | ||
} | ||
|
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,38 @@ | ||
<?php | ||
|
||
namespace TgLog; | ||
|
||
/** | ||
* Interface to make it easier to integrate other log implementations. | ||
*/ | ||
interface Logger { | ||
|
||
/** | ||
* Log the given string (and $object) in DEBUG level. | ||
* @param string $s - the string to be logged | ||
* @param mixed $object - an optional object that can be inspected (usually json-encoded in log) | ||
*/ | ||
public function debug(string $s, $object = NULL); | ||
|
||
/** | ||
* Log the given string (and $object) in DEBUG level. | ||
* @param string $s - the string to be logged | ||
* @param mixed $object - an optional object that can be inspected (usually json-encoded in log) | ||
*/ | ||
public function info(string $s, $object = NULL); | ||
|
||
/** | ||
* Log the given string (and $object) in WARN level. | ||
* @param string $s - the string to be logged | ||
* @param mixed $object - an optional object that can be inspected (usually json-encoded in log) | ||
*/ | ||
public function warn(string $s, $object = NULL); | ||
|
||
/** | ||
* Log the given string (and $object) in DEBUG level. | ||
* @param string $s - the string to be logged | ||
* @param mixed $object - an optional object that can be inspected (usually json-encoded in log) | ||
*/ | ||
public function error(string $s, $object = NULL); | ||
|
||
} |
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.