浏览代码

Merge pull request #204 from roowe/disable_pp_records

support disable pretty printing records encountered at compile time
pull/205/head
Andrew Thompson 11 年前
父节点
当前提交
46785b6541
共有 1 个文件被更改,包括 8 次插入1 次删除
  1. +8
    -1
      src/lager_transform.erl

+ 8
- 1
src/lager_transform.erl 查看文件

@ -30,6 +30,8 @@
%% @private %% @private
parse_transform(AST, Options) -> parse_transform(AST, Options) ->
TruncSize = proplists:get_value(lager_truncation_size, Options, ?DEFAULT_TRUNCATION), TruncSize = proplists:get_value(lager_truncation_size, Options, ?DEFAULT_TRUNCATION),
Enable = proplists:get_value(lager_print_records_flag, Options, true),
put(print_records_flag, Enable),
put(truncation_size, TruncSize), put(truncation_size, TruncSize),
erlang:put(records, []), erlang:put(records, []),
%% .app file should either be in the outdir, or the same dir as the source file %% .app file should either be in the outdir, or the same dir as the source file
@ -37,7 +39,12 @@ parse_transform(AST, Options) ->
walk_ast([], AST). walk_ast([], AST).
walk_ast(Acc, []) -> walk_ast(Acc, []) ->
insert_record_attribute(Acc);
case get(print_records_flag) of
true ->
insert_record_attribute(Acc);
false ->
lists:reverse(Acc)
end;
walk_ast(Acc, [{attribute, _, module, {Module, _PmodArgs}}=H|T]) -> walk_ast(Acc, [{attribute, _, module, {Module, _PmodArgs}}=H|T]) ->
%% A wild parameterized module appears! %% A wild parameterized module appears!
put(module, Module), put(module, Module),

正在加载...
取消
保存