slog.function.php 918 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. require 'slog.php';
  3. use think\org\Slog;
  4. function slog($log, $type = 'log', $css = '')
  5. {
  6. if (is_string($type)) {
  7. $type = preg_replace_callback('/_([a-zA-Z])/', function ($matches) {
  8. return strtoupper($matches[1]);
  9. }, $type);
  10. if (method_exists('\think\org\Slog', $type) || in_array($type, Slog::$log_types)) {
  11. return call_user_func(array('\think\org\Slog', $type), $log, $css);
  12. }
  13. }
  14. if (is_object($type) && 'mysqli' == get_class($type)) {
  15. return Slog::mysqlilog($log, $type);
  16. }
  17. if (is_resource($type) && ('mysql link' == get_resource_type($type) || 'mysql link persistent' == get_resource_type($type))) {
  18. return Slog::mysqllog($log, $type);
  19. }
  20. if (is_object($type) && 'PDO' == get_class($type)) {
  21. return Slog::pdolog($log, $type);
  22. }
  23. throw new Exception($type . ' is not SocketLog method');
  24. }