API接口明细记录 记录日志 日志

/**
 *
 * API接口明细记录
 * @param $uid
 * @param string $classify 模块
 * @param string $type 变动类型
 * @param string $url 接口地址
 * @param string $content 发送内容
 * @param string $result 返回值
 * @return bool
 */
function apilog($classify, $type, $url, $content, $result)
{
    $destination = RUNTIME_PATH . 'log' . DS . date("Ym") . DS . date('d') . 'api.log';
    $path = dirname($destination);
    !is_dir($path) && mkdir($path, 0755, true);

    if (is_file($destination) && floor(2097152) <= filesize($destination)) {
        rename($destination, dirname($destination) . DS . time() . '-' . basename($destination));
    }

    $now = '[ 创建时间 ] ' . date("Y-m-d H:i:s");
    $localurl = '[ 运行链接 ] ' . getUrl();
    $classify = '[ 模块 ] ' . $classify;
    $type = '[ 类型 ] ' . $type;
    $url = '[ 接口链接 ] ' . $url;
    $message = "---------------------------------------------------------------\r\n{$now}\r\n{$localurl}\r\n{$classify}\r\n{$type}\r\n{$url}\r\n";

    $f = fopen($destination, 'a');
    $file = fwrite($f, print_r($message . '[ 接口内容 ] ', true));
    $file = fwrite($f, print_r($content, true));
    $file = fwrite($f, print_r("\r\n[ 接口返回结果 ] ", true));
    $file = fwrite($f, print_r($result, true));
    $file = fwrite($f, print_r("\r\n\r\n", true));
    return true;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

昊喵喵博士

大哥你真帅,小姐姐你真漂亮

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值