From 7ff83587b617a0b2962e54202695ccc6c2f744fa Mon Sep 17 00:00:00 2001 From: augushong Date: Sun, 16 Aug 2026 07:28:27 +0800 Subject: [PATCH] =?UTF-8?q?feat(log):=20=E6=96=B0=E5=A2=9E=20ul=5Fdebug=5F?= =?UTF-8?q?log=5Fposition=20=E8=A1=A8=EF=BC=88migration+scheme+model?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/model/DebugLogPosition.php | 27 +++++++++ app/admin/scheme/DebugLogPosition.php | 56 +++++++++++++++++++ .../20260815100001_debug_log_position.php | 31 ++++++++++ 3 files changed, 114 insertions(+) create mode 100644 app/admin/model/DebugLogPosition.php create mode 100644 app/admin/scheme/DebugLogPosition.php create mode 100644 database/migrations/20260815100001_debug_log_position.php diff --git a/app/admin/model/DebugLogPosition.php b/app/admin/model/DebugLogPosition.php new file mode 100644 index 0000000..9f64ac5 --- /dev/null +++ b/app/admin/model/DebugLogPosition.php @@ -0,0 +1,27 @@ +table('debug_log_position', ['id' => false, 'primary_key' => ['id']]) + ->setComment('调试日志文件读取位置(增量读取状态)') + ->addColumn('id', 'integer', ['limit' => 11, 'null' => false, 'signed' => false, 'identity' => true, 'comment' => '主键ID']) + ->addColumn('node_id', 'string', ['limit' => 64, 'null' => false, 'default' => '', 'comment' => '节点ID(区分不同采集节点)']) + ->addColumn('file_path', 'string', ['limit' => 500, 'null' => false, 'comment' => '日志文件绝对路径']) + ->addColumn('inode', 'biginteger', ['default' => 0, 'comment' => '文件 inode,用于检测日志轮转', 'signed' => false]) + ->addColumn('offset', 'biginteger', ['default' => 0, 'comment' => '上次读取到的字节偏移', 'signed' => false]) + ->addColumn('last_read_time', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '上次读取时间戳', 'signed' => false]) + ->addColumn('last_line_hash', 'string', ['limit' => 32, 'default' => '', 'comment' => '上次最后一行的 md5 哈希(容错校验)']) + ->addColumn('parse_fail_count', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '解析失败累计次数', 'signed' => false]) + ->addColumn('parse_fail_samples', 'text', ['null' => true, 'comment' => '解析失败样本行(最多保留若干条)']) + ->addColumn('create_time', 'integer', ['limit' => 11, 'comment' => '创建时间戳', 'signed' => false]) + ->addColumn('update_time', 'integer', ['limit' => 11, 'comment' => '更新时间戳', 'signed' => false]) + ->addIndex(['node_id', 'file_path'], ['unique' => true, 'name' => 'uniq_node_file']) + ->create(); + } +}