debug.func.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * The debug helpers file of zin of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2023 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
  6. * @author Hao Sun <sunhao@easycorp.ltd>
  7. * @package zin
  8. * @version $Id
  9. * @link https://www.zentao.net
  10. */
  11. namespace zin\utils;
  12. $logs = array();
  13. function log($type, $msg = null, $file)
  14. {
  15. global $config, $logs;
  16. if(!$config->debug) return;
  17. if($msg === null)
  18. {
  19. $msg = $type;
  20. $type = 'i';
  21. }
  22. if(is_array($msg))
  23. {
  24. $msgLines = array();
  25. foreach($msg as $m) $msgLines[] = strval($m);
  26. $msg = implode(' ', $msgLines);
  27. }
  28. else
  29. {
  30. $msg = strval($msg);
  31. }
  32. $logs[] = array(array('type' => strtolower($type), 'msg' => $msg));
  33. }
  34. function logInfo($msg, $file = null) {log('i', $msg, $file);};
  35. function logWarn($msg, $file = null) {log('w', $msg, $file);};
  36. function logError($msg, $file = null) {log('e', $msg, $file);};