心理咨询网
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * @copyright (C)2016-2099 Hnaoyun Inc.
  4. * @author XingMeng
  5. * @email hnxsh@foxmail.com
  6. * @date 2017年10月24日
  7. * 日志统一调用类
  8. */
  9. namespace core\basic;
  10. use core\log\LogText;
  11. use core\log\LogDb;
  12. class Log
  13. {
  14. // 获取缓存实例
  15. protected static function getLogInstance()
  16. {
  17. switch (Config::get('log_record_type')) {
  18. case 'text':
  19. $instance = LogText::getInstance();
  20. break;
  21. case 'db':
  22. $instance = LogDb::getInstance();
  23. break;
  24. default:
  25. $instance = LogText::getInstance();
  26. }
  27. return $instance;
  28. }
  29. /**
  30. * 日志写入
  31. *
  32. * @param string $content
  33. * 日志内容
  34. * @param string $level
  35. * 内容级别
  36. */
  37. public static function write($content, $level = "info", $username = null)
  38. {
  39. $log = self::getLogInstance();
  40. $log->write($content, $level, $username);
  41. }
  42. /**
  43. * 错误日志快速写入,error级别
  44. *
  45. * @param string $content
  46. * 日志内容
  47. */
  48. public static function error($content)
  49. {
  50. $log = self::getLogInstance();
  51. $log->error($content);
  52. }
  53. /**
  54. * 基础日志快速写入, info级别
  55. *
  56. * @param string $content
  57. * 日志内容
  58. */
  59. public static function info($content)
  60. {
  61. $log = self::getLogInstance();
  62. $log->info($content);
  63. }
  64. }