slog.function.php 923 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. require 'slog.class.php';
  3. use think\slog\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\slog\Slog', $type) || in_array($type, Slog::$log_types)) {
  11. return call_user_func(['\think\slog\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. }