From 040eb0df7a549842a7636afda94665bd8d0c22e4 Mon Sep 17 00:00:00 2001 From: dingguodong Date: Wed, 3 Apr 2024 11:20:12 +0800 Subject: [PATCH] + Add a debug helper for recording any message to log file. --- framework/router.class.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/framework/router.class.php b/framework/router.class.php index ca90bddbec..fa7978c478 100755 --- a/framework/router.class.php +++ b/framework/router.class.php @@ -378,6 +378,24 @@ class router extends baseRouter parent::saveError($level, $message, $file, $line); } + /** + * Save any message with any type to the php log file which prefix with 'php.'. + * A debug helper. + * + * @param mixed $message + * @param string $file + * @param int $line + * @return void + */ + public function debug($message = '', $file = 'undefined', $line = 0) + { + if(!is_string($message)) $message = (string)json_encode($message, JSON_PRETTY_PRINT); + + if(empty($file) || $file == 'undefined') $message .= (new Exception())->getTraceAsString(); + + $this->saveError(E_USER_WARNING, $message, $file, $line); + } + /** * 企业版部分功能是从然之合并过来的。然之代码中调用loadModuleConfig方法时传递了一个非空的appName,在禅道中会导致错误。 * 把appName设置为空来避免这个错误。