| 123456789101112131415161718192021222324252627282930313233 |
- <?php
- namespace Tests\Dev;
- use Tests\TestCase;
- use UCore\Helper\Logger;
- /**
- * 测试Logger::exception格式化演示
- */
- class TestLoggerExceptionDemo extends TestCase
- {
- /**
- * 测试新的异常日志格式
- */
- public function testNewLoggerExceptionFormat()
- {
- try {
- // 故意触发一个异常
- throw new \Exception("这是一个测试异常,用于演示新的日志格式");
- } catch (\Exception $e) {
- // 使用新的Logger::exception方法记录异常
- Logger::exception('测试新的异常日志格式', $e, [
- 'test_data' => '这是测试数据',
- 'user_id' => 12345,
- 'action' => 'format_test'
- ]);
- }
-
- // 测试通过
- $this->assertTrue(true);
- }
- }
|