1

我正在使用dynamic_compile来动态创建logger。通过钢筋启动时显示错误,但正常启动时正确。请帮忙看看。这是我在 github 上的小演示项目

以下是我的步骤:

步报错误:

~/rebar_test > rebar compile generate
~/rebar_test > ./rel/server/bin/server console

然后得到错误:

=CRASH REPORT==== 4-Dec-2012::20:37:19 ===
  crasher:
    initial call: application_master:init/4
    pid: <0.48.0>
    registered_name: []
    exception exit: {bad_return,
                        {{yg_server_app,start,[normal,[]]},
                         {'EXIT',
                             {undef,
                                 [{logger,info_msg,
                                      [d,29,
                                       "Error compiling logger (~p): ~p~n",
                                       [error,undef]],
                                      []},
                                  {yg_server_app,start,2,
                                      [{file,"src/yg_server_app.erl"},
                                       {line,20}]},
                                  {application_master,start_supervisor,3,
                                      [{file,"application_master.erl"},
                                       {line,328}]},
                                  {application_master,start_the_app,5,
                                      [{file,"application_master.erl"},
                                       {line,310}]},
                                  {application_master,start_it_new,7,
                                      [{file,"application_master.erl"},
                                       {line,296}]}]}}}}
      in function  application_master:init/4 (application_master.erl, line 138)
    ancestors: [<0.47.0>]
    messages: [{'EXIT',<0.49.0>,normal}]
    links: [<0.47.0>,<0.6.0>]
    dictionary: []
    trap_exit: true
    status: running
    heap_size: 1597
    stack_size: 24
    reductions: 216
  neighbours:

正确步骤:

erl -pa apps/server/ebin -s server_app start

它告诉正确的:

Mod=logger,Code=<<70,79,82,49,0,0,3,244,66,69,65,77,65,116,111,109,0,0,0,173,0,
              0,0,19,6,108,111,103,103,101,114,3,103,101,116,8,116,101,115,
              116,95,109,115,103,2,111,107,9,100,101,98,117,103,95,109,115,
              103,8,105,110,102,111,95,109,115,103,11,119,97,114,110,105,
              110,103,95,109,115,103,9,101,114,114,111,114,95,109,115,103,
              12,99,114,105,116,105,99,97,108,95,109,115,103,6,101,114,108,
              97,110,103,2,43,43,4,115,101,108,102,5,101,114,114,111,114,6,
              110,111,116,105,102,121,12,103,114,111,117,112,95,108,101,97,
              100,101,114,12,101,114,114,111,114,95,108,111,103,103,101,
              114,9,103,101,110,95,101,118,101,110,116,11,109,111,100,117,
              108,101,95,105,110,102,111,15,103,101,116,95,109,111,100,117,
              108,101,95,105,110,102,111,0,0,0,67,111,100,101,0,0,1,31,0,0,
              0,16,0,0,0,0,0,0,0,153,0,0,0,21,0,0,0,10,1,16,153,16,2,18,34,
              0,1,32,64,17,3,19,1,48,153,32,2,18,50,64,1,64,64,66,3,19,1,
              80,153,48,2,18,82,64,1,96,64,66,3,19,1,112,153,64,2,18,98,64,
              1,128,64,66,3,19,1,144,153,80,2,18,114,64,1,160,64,66,3,19,1,
              176,153,96,2,18,130,64,1,192,64,66,3,19,1,208,153,112,2,18,
              146,64,1,224,12,48,64,64,3,36,64,19,20,64,71,0,19,64,35,3,64,
              51,4,153,128,7,32,0,64,3,19,64,71,16,3,153,128,7,32,0,16,96,
              16,9,16,19,69,20,4,51,69,36,51,51,69,19,51,35,64,3,19,64,210,
              3,5,48,13,16,48,1,240,153,144,2,18,226,48,1,8,16,12,48,48,64,
              35,4,64,19,20,64,3,36,153,160,7,0,32,16,128,16,9,16,19,70,48,
              35,71,19,71,20,71,4,70,48,19,71,36,71,3,71,35,64,10,16,3,153,
              176,8,32,48,48,1,8,17,153,0,2,18,10,18,0,1,8,18,64,18,3,153,
              0,78,16,64,1,8,19,153,0,2,18,10,18,16,1,8,20,64,3,19,64,18,3,
              153,0,78,32,80,3,0,83,116,114,84,0,0,0,0,73,109,112,84,0,0,0,
              76,0,0,0,6,0,0,0,10,0,0,0,11,0,0,0,2,0,0,0,10,0,0,0,12,0,0,0,
              0,0,0,0,10,0,0,0,15,0,0,0,0,0,0,0,17,0,0,0,14,0,0,0,2,0,0,0,
              10,0,0,0,19,0,0,0,1,0,0,0,10,0,0,0,19,0,0,0,2,69,120,112,84,
              0,0,0,112,0,0,0,9,0,0,0,18,0,0,0,1,0,0,0,20,0,0,0,18,0,0,0,0,
              0,0,0,18,0,0,0,9,0,0,0,4,0,0,0,14,0,0,0,8,0,0,0,4,0,0,0,12,0,
              0,0,7,0,0,0,4,0,0,0,10,0,0,0,6,0,0,0,4,0,0,0,8,0,0,0,5,0,0,0,
              4,0,0,0,6,0,0,0,3,0,0,0,4,0,0,0,4,0,0,0,2,0,0,0,0,0,0,0,2,76,
              105,116,84,0,0,0,42,0,0,0,36,120,156,99,96,96,96,98,96,96,96,
              107,206,102,96,170,203,3,178,132,128,44,62,103,141,186,2,43,
              48,210,84,176,82,0,0,101,252,7,63,0,0,76,111,99,84,0,0,0,16,
              0,0,0,1,0,0,0,14,0,0,0,3,0,0,0,16,65,116,116,114,0,0,0,40,
              131,108,0,0,0,1,104,2,100,0,3,118,115,110,108,0,0,0,1,110,16,
              0,8,200,37,56,188,135,98,70,208,71,217,156,243,203,95,210,
              106,106,67,73,110,102,0,0,0,123,131,108,0,0,0,4,104,2,100,0,
              7,111,112,116,105,111,110,115,106,104,2,100,0,7,118,101,114,
              115,105,111,110,107,0,5,52,46,56,46,50,104,2,100,0,4,116,105,
              109,101,104,6,98,0,0,7,220,97,12,97,4,97,13,97,3,97,6,104,2,
              100,0,6,115,111,117,114,99,101,107,0,43,47,85,115,101,114,
              115,47,115,117,121,101,106,117,110,47,68,111,99,117,109,101,
              110,116,115,47,112,114,111,106,101,99,116,47,114,101,98,97,
              114,95,116,101,115,116,106,0,65,98,115,116,0,0,0,0,76,105,
              110,101,0,0,0,43,0,0,0,0,0,0,0,0,0,0,0,16,0,0,0,11,0,0,0,1,
              18,177,225,9,20,9,26,9,32,9,38,9,50,9,52,9,57,9,58,9,59,0,0,0>
4

1 回答 1

1

这引起了我的注意:

"Error compiling logger (~p): ~p~n",
[error,undef]],

我认为您需要添加compilerto rel/reltool.config,否则您将无法在运行时编译模块。

于 2012-12-04T14:40:27.330 回答