# 一些工具 **Repository Path**: brisklan/bs-tools ## Basic Information - **Project Name**: 一些工具 - **Description**: 一些自己常用的工具,有自己开发的,也有收集的,记录一下方便自己需要的时候直接用 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-06-03 - **Last Updated**: 2025-06-03 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 一些工具 #### 介绍 一些自己常用的工具,有自己开发的,也有收集的,记录一下方便自己需要的时候直接用 ##### 一、php日志类,封装了日志的写入功能,方便使用,默认写入到本地文件,可以自定义日志文件路径和日志级别,还可以扩展到mongodb、curl ```php use bs\tools\FileLogs; require __DIR__ . '/FileLogs.php'; //设置保存位置 FileLogs::setBaseDir(__DIR__ . 'runtime/logs/'); //设置驱动 FileLogs::setDriver('file');//默认 //通用模式 FileLogs::log('test.log', 'test', 'debug'); //debug模式 FileLogs::debug('test.log', 'test'); //info模式 FileLogs::info('test.log', 'test'); //带路径 FileLogs::log('abc/test.log', 'test'); //数组,没有占位符自动转换json格式 FileLogs::log('test.log', ['name' => 'test']); //带占位符 FileLogs::log('test.log', 'testa {name}', 'debug', ['name' => '替换后的A']); FileLogs::info('test.log', 'testb {name}', ['name' => '替换后的B']); //结果 [2025-06-03 23:20:11] [DEBUG] test [2025-06-03 23:20:11] [DEBUG] test [2025-06-03 23:20:11] [INFO] test [2025-06-03 23:20:11] [INFO] {"name":"test"} [2025-06-03 23:20:11] [DEBUG] testa 替换后的A [2025-06-03 23:20:11] [INFO] testb 替换后的B ```