Example #1
0
/**
 * github: https://github.com/luofei614/SocketLog
 * @author luofei614<weibo.com/luofei614>
 */
function slog($log, $type = 'log', $css = '')
{
    if (is_string($type)) {
        $type = preg_replace_callback('/_([a-zA-Z])/', create_function('$matches', 'return strtoupper($matches[1]);'), $type);
        if (method_exists('SocketLog', $type) || in_array($type, SocketLog::$log_types)) {
            return call_user_func(array('SocketLog', $type), $log, $css);
        }
    }
    if (is_object($type) && 'mysqli' == get_class($type)) {
        return SocketLog::mysqlilog($log, $type);
    }
    if (is_resource($type) && ('mysql link' == get_resource_type($type) || 'mysql link persistent' == get_resource_type($type))) {
        return SocketLog::mysqllog($log, $type);
    }
    if (is_object($type) && 'PDO' == get_class($type)) {
        return SocketLog::pdolog($log, $type);
    }
    throw new Exception($type . ' is not SocketLog method');
}