@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | public function __construct($channel = '') { |
| 25 | 25 | |
| 26 | 26 | $this->minDebugLevel = ($_ENV['APP_DEBUG_LEVEL'] ?: 'DEBUG'); |
| 27 | - if(!empty($channel)) { |
|
| 27 | + if (!empty($channel)) { |
|
| 28 | 28 | $this->channel = $channel; |
| 29 | 29 | //TODO: get channel options |
| 30 | 30 | } else { |
@@ -180,35 +180,35 @@ discard block |
||
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | $isEnabled = false; |
| 183 | - if(isset($_ENV['APP_LOG_TELEGRAM'])) { |
|
| 183 | + if (isset($_ENV['APP_LOG_TELEGRAM'])) { |
|
| 184 | 184 | $APP_LOG_TELEGRAM = trim(strtolower($_ENV['APP_LOG_TELEGRAM'])); |
| 185 | - if($APP_LOG_TELEGRAM === 'on' || $APP_LOG_TELEGRAM === 'true' || $APP_LOG_TELEGRAM === '1') { |
|
| 185 | + if ($APP_LOG_TELEGRAM === 'on' || $APP_LOG_TELEGRAM === 'true' || $APP_LOG_TELEGRAM === '1') { |
|
| 186 | 186 | $isEnabled = true; |
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - if(!isset($_ENV['APP_LOG_TELEGRAM_KEY']) || empty($_ENV['APP_LOG_TELEGRAM_KEY'])) { |
|
| 190 | + if (!isset($_ENV['APP_LOG_TELEGRAM_KEY']) || empty($_ENV['APP_LOG_TELEGRAM_KEY'])) { |
|
| 191 | 191 | $isEnabled = false; |
| 192 | 192 | } |
| 193 | - if(!isset($_ENV['APP_LOG_TELEGRAM_CHANNEL']) || empty($_ENV['APP_LOG_TELEGRAM_CHANNEL'])) { |
|
| 193 | + if (!isset($_ENV['APP_LOG_TELEGRAM_CHANNEL']) || empty($_ENV['APP_LOG_TELEGRAM_CHANNEL'])) { |
|
| 194 | 194 | $isEnabled = false; |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - if(!$isEnabled) { |
|
| 197 | + if (!$isEnabled) { |
|
| 198 | 198 | return; |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | $sender = new TelegramBotHandler($_ENV['APP_LOG_TELEGRAM_KEY'], $_ENV['APP_LOG_TELEGRAM_CHANNEL']); |
| 202 | 202 | |
| 203 | - if(isset($context['parse_mode']) && !empty($context['parse_mode'])) { |
|
| 203 | + if (isset($context['parse_mode']) && !empty($context['parse_mode'])) { |
|
| 204 | 204 | $sender->setParseMode($context['parse_mode']); |
| 205 | 205 | unset($context['parse_mode']); |
| 206 | 206 | } |
| 207 | - if(isset($context['disable_notification']) && $context['disable_notification'] === true) { |
|
| 207 | + if (isset($context['disable_notification']) && $context['disable_notification'] === true) { |
|
| 208 | 208 | $sender->disableNotification(true); |
| 209 | 209 | unset($context['disable_notification']); |
| 210 | 210 | } |
| 211 | - if(isset($context['disable_preview']) && $context['disable_preview'] === true) { |
|
| 211 | + if (isset($context['disable_preview']) && $context['disable_preview'] === true) { |
|
| 212 | 212 | $sender->disableWebPagePreview(true); |
| 213 | 213 | unset($context['disable_preview']); |
| 214 | 214 | } |
@@ -226,9 +226,9 @@ discard block |
||
| 226 | 226 | */ |
| 227 | 227 | private function formatMessage($message) { |
| 228 | 228 | |
| 229 | - if($message instanceof \Exception || $message instanceof Error) { |
|
| 229 | + if ($message instanceof \Exception || $message instanceof Error) { |
|
| 230 | 230 | $message = (string) $message; |
| 231 | - } else if(is_array($message) || is_object($message)) { |
|
| 231 | + } else if (is_array($message) || is_object($message)) { |
|
| 232 | 232 | $message = json_encode((array) $message, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); |
| 233 | 233 | $message = str_replace('\\u0000', '', $message); |
| 234 | 234 | } |
@@ -240,15 +240,15 @@ discard block |
||
| 240 | 240 | */ |
| 241 | 241 | public function getLogger() { |
| 242 | 242 | |
| 243 | - if(Registry::hasLogger($this->channel)) { |
|
| 243 | + if (Registry::hasLogger($this->channel)) { |
|
| 244 | 244 | return Registry::getInstance($this->channel); |
| 245 | 245 | } |
| 246 | 246 | $logPath = $_SERVER['DOCUMENT_ROOT'] . ($_ENV['APP_LOG_FOLDER'] ?: '/log/'); |
| 247 | 247 | $logPath .= $this->channel . '/' . date('Y-m-d') . '.log'; |
| 248 | 248 | $logDir = pathinfo($logPath, PATHINFO_DIRNAME); |
| 249 | - if(!file_exists($logDir)) { |
|
| 249 | + if (!file_exists($logDir)) { |
|
| 250 | 250 | $mode = 0775; |
| 251 | - if(defined('BX_DIR_PERMISSIONS') && BX_DIR_PERMISSIONS) { |
|
| 251 | + if (defined('BX_DIR_PERMISSIONS') && BX_DIR_PERMISSIONS) { |
|
| 252 | 252 | $mode = BX_DIR_PERMISSIONS; |
| 253 | 253 | } |
| 254 | 254 | mkdir($logDir, $mode, true); |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | |
| 272 | 272 | $levels = Logger::getLevels(); |
| 273 | 273 | |
| 274 | - if($this->minDebugLevel && isset($levels[$this->minDebugLevel])) { |
|
| 274 | + if ($this->minDebugLevel && isset($levels[$this->minDebugLevel])) { |
|
| 275 | 275 | return $levels[$this->minDebugLevel]; |
| 276 | 276 | } else { |
| 277 | 277 | return Logger::DEBUG; |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | $min_level = $this->getMinErrorLevel(); |
| 292 | - if($level >= $min_level) { |
|
| 292 | + if ($level >= $min_level) { |
|
| 293 | 293 | return true; |
| 294 | 294 | } |
| 295 | 295 | return false; |