diff options
Diffstat (limited to 'vendor/psr/log/src/LoggerTrait.php')
| -rw-r--r-- | vendor/psr/log/src/LoggerTrait.php | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/vendor/psr/log/src/LoggerTrait.php b/vendor/psr/log/src/LoggerTrait.php new file mode 100644 index 0000000..9c8733f --- /dev/null +++ b/vendor/psr/log/src/LoggerTrait.php | |||
| @@ -0,0 +1,142 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | namespace Psr\Log; | ||
| 4 | |||
| 5 | /** | ||
| 6 | * This is a simple Logger trait that classes unable to extend AbstractLogger | ||
| 7 | * (because they extend another class, etc) can include. | ||
| 8 | * | ||
| 9 | * It simply delegates all log-level-specific methods to the `log` method to | ||
| 10 | * reduce boilerplate code that a simple Logger that does the same thing with | ||
| 11 | * messages regardless of the error level has to implement. | ||
| 12 | */ | ||
| 13 | trait LoggerTrait | ||
| 14 | { | ||
| 15 | /** | ||
| 16 | * System is unusable. | ||
| 17 | * | ||
| 18 | * @param string|\Stringable $message | ||
| 19 | * @param array $context | ||
| 20 | * | ||
| 21 | * @return void | ||
| 22 | */ | ||
| 23 | public function emergency(string|\Stringable $message, array $context = []): void | ||
| 24 | { | ||
| 25 | $this->log(LogLevel::EMERGENCY, $message, $context); | ||
| 26 | } | ||
| 27 | |||
| 28 | /** | ||
| 29 | * Action must be taken immediately. | ||
| 30 | * | ||
| 31 | * Example: Entire website down, database unavailable, etc. This should | ||
| 32 | * trigger the SMS alerts and wake you up. | ||
| 33 | * | ||
| 34 | * @param string|\Stringable $message | ||
| 35 | * @param array $context | ||
| 36 | * | ||
| 37 | * @return void | ||
| 38 | */ | ||
| 39 | public function alert(string|\Stringable $message, array $context = []): void | ||
| 40 | { | ||
| 41 | $this->log(LogLevel::ALERT, $message, $context); | ||
| 42 | } | ||
| 43 | |||
| 44 | /** | ||
| 45 | * Critical conditions. | ||
| 46 | * | ||
| 47 | * Example: Application component unavailable, unexpected exception. | ||
| 48 | * | ||
| 49 | * @param string|\Stringable $message | ||
| 50 | * @param array $context | ||
| 51 | * | ||
| 52 | * @return void | ||
| 53 | */ | ||
| 54 | public function critical(string|\Stringable $message, array $context = []): void | ||
| 55 | { | ||
| 56 | $this->log(LogLevel::CRITICAL, $message, $context); | ||
| 57 | } | ||
| 58 | |||
| 59 | /** | ||
| 60 | * Runtime errors that do not require immediate action but should typically | ||
| 61 | * be logged and monitored. | ||
| 62 | * | ||
| 63 | * @param string|\Stringable $message | ||
| 64 | * @param array $context | ||
| 65 | * | ||
| 66 | * @return void | ||
| 67 | */ | ||
| 68 | public function error(string|\Stringable $message, array $context = []): void | ||
| 69 | { | ||
| 70 | $this->log(LogLevel::ERROR, $message, $context); | ||
| 71 | } | ||
| 72 | |||
| 73 | /** | ||
| 74 | * Exceptional occurrences that are not errors. | ||
| 75 | * | ||
| 76 | * Example: Use of deprecated APIs, poor use of an API, undesirable things | ||
| 77 | * that are not necessarily wrong. | ||
| 78 | * | ||
| 79 | * @param string|\Stringable $message | ||
| 80 | * @param array $context | ||
| 81 | * | ||
| 82 | * @return void | ||
| 83 | */ | ||
| 84 | public function warning(string|\Stringable $message, array $context = []): void | ||
| 85 | { | ||
| 86 | $this->log(LogLevel::WARNING, $message, $context); | ||
| 87 | } | ||
| 88 | |||
| 89 | /** | ||
| 90 | * Normal but significant events. | ||
| 91 | * | ||
| 92 | * @param string|\Stringable $message | ||
| 93 | * @param array $context | ||
| 94 | * | ||
| 95 | * @return void | ||
| 96 | */ | ||
| 97 | public function notice(string|\Stringable $message, array $context = []): void | ||
| 98 | { | ||
| 99 | $this->log(LogLevel::NOTICE, $message, $context); | ||
| 100 | } | ||
| 101 | |||
| 102 | /** | ||
| 103 | * Interesting events. | ||
| 104 | * | ||
| 105 | * Example: User logs in, SQL logs. | ||
| 106 | * | ||
| 107 | * @param string|\Stringable $message | ||
| 108 | * @param array $context | ||
| 109 | * | ||
| 110 | * @return void | ||
| 111 | */ | ||
| 112 | public function info(string|\Stringable $message, array $context = []): void | ||
| 113 | { | ||
| 114 | $this->log(LogLevel::INFO, $message, $context); | ||
| 115 | } | ||
| 116 | |||
| 117 | /** | ||
| 118 | * Detailed debug information. | ||
| 119 | * | ||
| 120 | * @param string|\Stringable $message | ||
| 121 | * @param array $context | ||
| 122 | * | ||
| 123 | * @return void | ||
| 124 | */ | ||
| 125 | public function debug(string|\Stringable $message, array $context = []): void | ||
| 126 | { | ||
| 127 | $this->log(LogLevel::DEBUG, $message, $context); | ||
| 128 | } | ||
| 129 | |||
| 130 | /** | ||
| 131 | * Logs with an arbitrary level. | ||
| 132 | * | ||
| 133 | * @param mixed $level | ||
| 134 | * @param string|\Stringable $message | ||
| 135 | * @param array $context | ||
| 136 | * | ||
| 137 | * @return void | ||
| 138 | * | ||
| 139 | * @throws \Psr\Log\InvalidArgumentException | ||
| 140 | */ | ||
| 141 | abstract public function log($level, string|\Stringable $message, array $context = []): void; | ||
| 142 | } | ||
