首页 > 编程知识 正文

figure和character的区别,translator interpreter区别

时间:2023-05-04 04:31:29 阅读:154617 作者:1612

Parse Transform Lager最有趣的地方之一是每次打印日志时都会显示模块名称/函数名称/行号。 另外,不是使用的宏。 其诀窍是在编译时添加{parse_tranform,lager_transform}选项

Erlang官方介绍如下

在编译{parse_transform,module}ERL文件时,如果参考上述字段,则在文件生成abstract code之后,Module:parse_transform/2

Lager项目是使用上述选项实现的代码转换。 例如,在代码中调用的lager:debug/info/error是在服务启动后找到相关函数并在上述编译后实际调用的lager:dispatch_log/9

获取用于创建abstract code的简单模块

-module(hello ).- export ([ hello/0 ] ).hello ) )-io:format ),you are so cool! 获取~n ',[].abstractcode

Eshellv7.3(Abortwith^g ) 1c({Hello,[debug_info] ).ok,Hello}2RP ) Beam_lib3360chunks ) hello,[ abst ranfo {attribute,1,module,hello},{attribute} [],[],[{call,6,{remote,6,{atom,6,io},{atom,6,6 } {eof,7 } } }打开ok调整模块,调用lager调用,自行获取abstract code匹配parse_transform/2处理时,发现lager330

-module(hello ).-compile([{parse_transform,lager _ transform } ].- export ([ hello/0 ].hello ) ) )-) ~n ',[] ) .编译完成后,反编译可以获取代码的实际转换内容

-module(hello ).- lager _ records ([ ].- compile ([ ].- export ) [hello/0] ).hello )-case { where is } [ ] {__Pidhello6,{__Levelhello6,_ _ traces hello6} } when _ level hello 6b and 64/=0or else _ _ traces hello6/mslo PID_to_list(self ) },{node,node ~n ',[],4096,64,__Levelhello6,__Traceshello6,__Pidhello6 _ - ok end,io:format(Helloauthor,you are so cool! (n )、[ ]。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。