<p align="center">
<img src="https://yellow-cdn.veclightyear.com/ab5030c0/e0b23897-cd9f-4c21-a9fd-6bb7d714666c.png" width="230"/>
</p>
<p align="center">
日志文件高亮工具
</p>
<p align="center">
<img src="https://yellow-cdn.veclightyear.com/ab5030c0/f2ceb17d-ef79-44ae-997a-8e21ac25bc4a.png" width="700"/>
</p>
特性
- 🪵 查看(或
tail
)任何格式的日志文件
- 🍰 无需设置或配置
- 🌈 高亮显示数字、日期、IP地址、UUID、URL等
- ⚙️ 所有高亮组都可自定义
- 🧬 易于与其他命令集成
- 🔍 底层使用
less
实现回滚、搜索和过滤
目录
概述
tailspin
通过逐行读取日志文件,对每行运行一系列正则表达式来工作。这些正则表达式识别您期望在日志文件中找到的模式,如日期、数字、严重性关键词等。
tailspin
不对要高亮的项目的格式或位置做任何假设。因此,它不需要配置,高亮效果可以在不同的日志文件中保持一致。
使用方法
tailspin
的二进制文件名是 tspin
。
# 从文件读取并在 `less` 中查看
tspin application.log
# 从文件读取并打印到 stdout
tspin application.log --print
# 从 stdin 读取并打印到 stdout
echo "2021-01-01 12:00:00 [INFO] 这是一条日志消息" | tspin
# 从其他命令读取并打印到 stdout
kubectl logs [pod name] --follow | tspin
安装
包管理器
# Homebrew
brew install tailspin
# Cargo
cargo install tailspin
# Archlinux
pacman -S tailspin
# Nix
nix-shell -p tailspin
# NetBSD
pkgin install tailspin
# FreeBSD
pkg install tailspin
从源码安装
cargo install --path .
二进制文件将被放置在 ~/.cargo/bin
,确保将该文件夹添加到您的 PATH
环境变量中。
[!重要]
从源码构建时,请确保您使用的是最新版本的 less
。
高亮组
日期
<p align="center">
<img src="https://yellow-cdn.veclightyear.com/ab5030c0/b319bd71-16b5-406a-924a-ce2b3c3d554d.png" width="600"/>
</p>
关键词
<p align="center">
<img src="https://yellow-cdn.veclightyear.com/ab5030c0/0f8349e9-c074-439c-815b-73e29aafdb99.png" width="600"/>
</p>
URL
<p align="center">
<img src="https://yellow-cdn.veclightyear.com/ab5030c0/efa58267-59ae-4454-97a0-9d0c0b227763.png" width="600"/>
</p>
数字
<p align="center">
<img src="https://yellow-cdn.veclightyear.com/ab5030c0/1efe64e3-1bfb-4794-9a15-4035b8a77eed.png" width="600"/>
</p>
IP 地址
<p align="center">
<img src="https://yellow-cdn.veclightyear.com/ab5030c0/9aa6a39e-ff15-425f-ae45-787a36cf5023.png" width="600"/>
</p>
引号
<p align="center">
<img src="https://yellow-cdn.veclightyear.com/ab5030c0/4146fe29-85c5-4d2e-84a4-b2f80b5eefc4.png" width="600"/>
</p>
Unix 文件路径
<p align="center">
<img src="https://yellow-cdn.veclightyear.com/ab5030c0/810bd46a-458f-4320-baac-96edba927e41.png" width="600"/>
</p>
HTTP 方法
<p align="center">
<img src="https://yellow-cdn.veclightyear.com/ab5030c0/d31fbada-47f7-4730-94f4-f7aeeb4e8983.png" width="600"/>
</p>
UUID
<p align="center">
<img src="https://yellow-cdn.veclightyear.com/ab5030c0/c9d09c53-68f6-4440-b7cf-296f80971ac6.png" width="600"/>
</p>