当前位置:网站首页>loggie 编码以及换行符测试
loggie 编码以及换行符测试
2022-06-26 10:09:00 【序冢--磊】
一、测试非编码单行换行符
1、测试场景
\r\n测试
pipeline配置文件:
pipelines:
- name: local
sources:
- type: file
name: demo
lineEnd:
type: carriage_return_line_feed
value: "\r\n"
charset: utf-8
paths:
- /home/zhanglei/*.log
fields:
topic: "loggie"
interceptors:
- type: iconv
charset: "utf-8"
sink:
type: dev
printEvents: true
codec:
pretty: true2、测试脚本
<?php
$a = "1ddsjaodjasiodjasoidjasoidjasid段晒苏杭怠速后端三十u的\r\n";
file_put_contents("a.log", $a, FILE_APPEND);
var_dump("1ddsjaodjasiodjasoidjasoidjasid段晒苏杭怠速后端三十u的");
3、测试结果

输出正常
二、测试编码单行换行符
1、测试场景
gbk 编码
\r\n测试
pipeline配置文件:
pipelines:
- name: local
sources:
- type: file
name: demo
lineEnd:
type: carriage_return_line_feed
value: "\r\n"
charset: gbk
paths:
- /home/zhanglei/*.log
fields:
topic: "loggie"
interceptors:
- type: iconv
charset: "gbk"
sink:
type: dev
printEvents: true
codec:
pretty: true2.测试脚本
<?php
$a = iconv("utf-8", "gbk", "哈哈哈顿巴斯涉及到八级大把货都不花钱我闻不到几千万望
变电气文件变动祭敖包\r\n");
file_put_contents("a.log", $a, FILE_APPEND);
var_dump($a);3.测试结果

三、测试非编码 auto 换行符
1、测试场景
\n测试
pipeline配置文件:
pipelines:
- name: local
sources:
- type: file
name: demo
lineEnd:
type: auto
paths:
- /home/zhanglei/*.log
fields:
topic: "loggie"
interceptors:
- type: iconv
sink:
type: dev
printEvents: true
codec:
pretty: true2.测试脚本
<?php
$a = "1ddsjaodjasiodjasoidjasoidjasid段晒苏杭怠速后端三十u的\r\n";
file_put_contents("b.log", $a, FILE_APPEND);
var_dump($a);
3.测试结果

四、测试编码 auto 换行符
1、测试场景
gbk 编码
\n测试
pipeline配置文件:
pipelines:
- name: local
sources:
- type: file
name: demo
lineEnd:
type: auto
value: "\r\n"
charset: gbk
paths:
- /home/zhanglei/*.log
fields:
topic: "loggie"
interceptors:
- type: iconv
charset: "gbk"
sink:
type: dev
printEvents: true
codec:
pretty: true2.测试脚本
<?php
$a = iconv("utf-8", "gbk", "哈哈哈顿巴斯涉及到八级大把货都不花钱我闻不到几千万望
变电气文件变动祭敖包\r\n");
file_put_contents("a.log", $a, FILE_APPEND);
var_dump($a);3.测试结果

五、测试非编码自定义换行符(特殊字符)
1、测试场景
pipeline:
pipelines:
- name: local
sources:
- type: file
name: demo
lineEnd:
type: custome
value: "\r\n"
paths:
- /home/zhanglei/*.log
fields:
topic: "loggie"
interceptors:
- type: iconv
sink:
type: dev
printEvents: true
codec:
pretty: true2、测试结果

3、结论
custom 配置不能解决 特殊ascii码问题
特殊字符使用
lineTerminators = map[string]LineTerminator{
"auto": AutoLineTerminator,
"line_feed": LineFeed,
"vertical_tab": VerticalTab,
"form_feed": FormFeed,
"carriage_return": CarriageReturn,
"carriage_return_line_feed": CarriageReturnLineFeed,
"next_line": NextLine,
"line_separator": LineSeparator,
"paragraph_separator": ParagraphSeparator,
"null_terminator": NullTerminator,
}六、测试非编码自定义换行符(非特殊字符)
1、测试场景
pipeline:
pipelines:
- name: local
sources:
- type: file
name: demo
lineEnd:
type: custom
value: "的"
paths:
- /home/zhanglei/*.log
fields:
topic: "loggie"
interceptors:
- type: iconv
sink:
type: dev
printEvents: true
codec:
pretty: true2、测试结果

3、结论
正常
七、测试编码自定义换行符(特殊字符)
1、测试场景
pipeline:
pipelines:
- name: local
sources:
- type: file
name: demo
lineEnd:
type: custom
value: "\r\n"
charset: gbk
paths:
- /home/zhanglei/*.log
fields:
topic: "loggie"
interceptors:
- type: iconv
charset: gbk
sink:
type: dev
printEvents: true
codec:
pretty: true2、测试结果

3、结论
custom 配置不能解决 特殊ascii码问题
但是可见字符都是正常的,如果出现不可见字符请使用
lineTerminators = map[string]LineTerminator{
"auto": AutoLineTerminator,
"line_feed": LineFeed,
"vertical_tab": VerticalTab,
"form_feed": FormFeed,
"carriage_return": CarriageReturn,
"carriage_return_line_feed": CarriageReturnLineFeed,
"next_line": NextLine,
"line_separator": LineSeparator,
"paragraph_separator": ParagraphSeparator,
"null_terminator": NullTerminator,
}解码后出现bug
八、测试编码自定义换行符(非特殊字符)
1、测试场景
pipeline:
pipelines:
- name: local
sources:
- type: file
name: demo
lineEnd:
type: custom
value: "\r\n"
charset: gbk
paths:
- /home/zhanglei/*.log
fields:
topic: "loggie"
interceptors:
- type: iconv
charset: gbk
sink:
type: dev
printEvents: true
codec:
pretty: true2、测试结果

3、结论
非特殊字符解码正常
边栏推荐
猜你喜欢

Alibaba cloud OSS - object storage service (tool)

Linux下安装Mysql【详细】

Redis knowledge mind map

3、 Linked list exercise

Swiftui development experience: data layer of application design for offline priority

ISO 26262 - 2 functional safety concept

nacos2.x.x启动报错信息Error creating bean with name ‘grpcClusterServer‘;

Query online users and forced withdrawal users based on oauth2

JS take the date of the previous month 【 pit filling 】
![Installing MySQL under Linux [details]](/img/38/77be56c3ef3923ce4c4e5df4a96f41.png)
Installing MySQL under Linux [details]
随机推荐
Plookup table in appliedzkp zkevm (8)
Unity使用SteamVRPlugin时如何不让其他Camera位置和旋转收到SteamVRPlugin控制
即构「畅直播」上线!提供全链路升级的一站式直播服务
How does unity prevent other camera positions and rotations from being controlled by steamvrplugin when using steamvrplugin
DataBinding使用与原理分析
Flutter and native communication (Part 1)
OpenCV图像处理-灰度处理
Opencv image processing - grayscale processing
Grain Mall - High Availability Cluster
互联网对抗神器之漏洞扫描与反渗透
Cereals Mall - Distributed Advanced
02-Redis数据结构之链表
磁带库简单记录1
Svn installation configuration
Nuxt. JS - learning notes
Redis (basic) - learning notes
【北邮果园微处理器设计】10 Serial Communication 串口通信笔记
SQL Server foundation introduction collation
(Typora图床)阿里云oss搭建图床+Picgo上传图片详细教程
Progressive web application PWA is the future of application development