watcher
简介
组件接口
ConfigD.gs
| 函数原型 | 函数作用 |
|---|---|
| ClassifyInfo get_default_classify_info() | 获取默认的分类信息, 兼容旧版本 |
| bool is_dev() | 判断当前是否处于开发模式 |
| string get_root_path() | 获取聚合日志保存路径 |
| bool is_watch_warning() | 是否监控警告 |
| map path_pattern() | 获取聚合日志保存路径的路径模式 |
| bool is_classify_by_group() | 发送到飞书群是否安装区组发送 |
HealthD.gs
| 函数原型 | 函数作用 |
|---|---|
| bool start_health_monitor(map m) | 启动健康检查 |
SenderD.gs
| 函数原型 | 函数作用 |
|---|---|
| string gen_token() | 根据规则, 产生 token |
TestD.gs
| 函数原型 | 函数作用 |
|---|---|
| void test() | 发送测试错误到服务器 |
| void test_server_addr() | 测试服务器上传地址是否正常 |
WatchDirRootD.gs
| 函数原型 | 函数作用 |
|---|---|
| void main_loop() | 处理是否有新增文件夹 |
| void init() | 初始化监听路径 |
Classify.gs
| 函数原型 | 函数作用 |
|---|---|
| void set_info(ClassifyInfo info) | 设置分类信息 |
| ClassifyInfo get_info() | 获取分类信息 |
WatchFile.gs
| 函数原型 | 函数作用 |
|---|---|
| buffer read_end(int start, int end) | 读取文件最后一部分数据, 规避 read_part seek 的 bug |
| int is_log_start(string des) | 如果该行前 24 个字符, 可以转换为时间戳, 则认为该行为一个错误日志的开始 |
| void set_classify_info(ClassifyInfo info) | 设置 分类信息 |
watcher.gs
| 函数原型 | 函数作用 |
|---|---|
| Task get_task() | 获取监听日志的任务 |
样例
boot();
void boot()
{
language.set_internal_encoding("UTF-8");
string os = get_system_info().os;
string encode = "UTF-8";
if (os == "windows")
encode = "GBK";
language.set_io_translator(this_coroutine().get_output(), language.get_internal_encoding(), encode);
string serer_addr = "http://localhost:8081/errors/server";
string app_id = "测试";
string group_id= "group_id";
string watch_id = "测试watch_id";
watcher.start(serer_addr, app_id, group_id, watch_id);
}