anchor.diff:  %% ====================================================================
   
   check_logs(ExpectedLogNumber) ->
  -  {StartTime, _} = statistics(wall_clock),
  -  {UnknownSourceLogs, ErrorLoggerLogs, LagerLogs} = count_logs(0, 0, 0, ExpectedLogNumber, StartTime),
  -
  -  %% 4/10 of logs should have been classified as of unknown source
  -  ?assertEqual(ExpectedLogNumber div 10 * 4, UnknownSourceLogs),
  -
  -  %% 2/10 of logs should have been classified as error_logger logs
  -  ?assertEqual(ExpectedLogNumber div 10 * 2, ErrorLoggerLogs),
  -
  -  %% 4/10 of logs should have been classified as standard lager logs
  -  ?assertEqual(ExpectedLogNumber div 10 * 4, LagerLogs).
  -
  -
  -count_logs(UnknownSourceLogs, ErrorLoggerLogs, LagerLogs, Expected, StartTime) -> 
  -  {CurrentTime, _} = statistics(wall_clock),
  -  case CurrentTime - StartTime < 5000 of
  -    false -> 
  -      {UnknownSourceLogs, ErrorLoggerLogs, LagerLogs};
  -    true ->
  -      case UnknownSourceLogs + ErrorLoggerLogs + LagerLogs of
  -        Expected -> 
  -          {UnknownSourceLogs, ErrorLoggerLogs, LagerLogs};
  -        _ ->
  -          receive 
  -            {log, {"test_log", _, _, [{node, _}, {source, unknown}]}} -> 
  -              count_logs(UnknownSourceLogs + 1, ErrorLoggerLogs, LagerLogs, Expected, StartTime);
  -
  -            {log, {"test_log", _, _, [{node, _}, {source, error_logger}, {pid, _}]}} -> 
  -              count_logs(UnknownSourceLogs, ErrorLoggerLogs + 1, LagerLogs, Expected, StartTime);
  -
  -            {log, {"test_log", _, _, Metadata}} -> 
  -              true = (proplists:get_value(node, Metadata) /= undefined), 
  -              count_logs(UnknownSourceLogs, ErrorLoggerLogs, LagerLogs + 1, Expected, StartTime)
  -
  -          after 100 ->
  -              count_logs(UnknownSourceLogs, ErrorLoggerLogs, LagerLogs, Expected, StartTime)
  -          end
  -      end
  -  end.
  -
  -
  +    {StartTime, _} = statistics(wall_clock),
  +    {ErrorLoggerLogs, LagerLogs} = count_logs(0, 0, ExpectedLogNumber, StartTime),
  +
  +    %% 4/10 of logs should have been classified as error_logger logs
  +    ?assertEqual(ExpectedLogNumber div 10 * 4, ErrorLoggerLogs),
  +
  +    %% 6/10 of logs should have been classified as standard lager logs
  +    ?assertEqual(ExpectedLogNumber div 10 * 6, LagerLogs).
  +
  +
  +count_logs(ErrorLoggerLogs, LagerLogs, Expected, StartTime) ->
  +    {CurrentTime, _} = statistics(wall_clock),
  +    case CurrentTime - StartTime < 5000 of
  +        false ->
  +            {ErrorLoggerLogs, LagerLogs};
  +        true ->
  +            case ErrorLoggerLogs + LagerLogs of
  +                Expected ->
  +                    {ErrorLoggerLogs, LagerLogs};
  +                _ ->
  +                    receive
  +                        {log, {"test_log", _, _, [{node, _}, {pid, _}]}} ->
  +                            count_logs(ErrorLoggerLogs + 1, LagerLogs, Expected, StartTime);
  +
  +                        {log, {"test_log", _, _, Metadata}} ->
  +                            true = (proplists:get_value(node, Metadata) /= undefined),
  +                            count_logs(ErrorLoggerLogs, LagerLogs + 1, Expected, StartTime)
  +
  +                    after 100 ->
  +                        count_logs(ErrorLoggerLogs, LagerLogs, Expected, StartTime)
  +                    end
  +            end
  +    end.
   
   
   %% ====================================================================
  
positive.code: %% ====================================================================
  
  init_per_testcase(logging_test, Config) ->
    ?INIT_DIST_TEST,
    nodes_manager:start_deps_for_tester_node(),
  
    Nodes = nodes_manager:start_test_on_nodes(5),
    [CCM | _] = Nodes,
  
    StartLog = nodes_manager:start_app_on_nodes(Nodes, 
      [[{node_type, ccm}, 
        {dispatcher_port, 5055}, 
        {ccm_nodes, [CCM]}, 
        {dns_port, 1308}, {control_panel_port, 2308}, {control_panel_redirect_port, 1354}, {rest_port, 3308}, {heart_beat, 1}],
      [{node_type, worker}, 
        {dispatcher_port, 5056}, 
        {ccm_nodes, [CCM]}, 
        {dns_port, 1309}, {control_panel_port, 2309}, {control_panel_redirect_port, 1355}, {rest_port, 3309}, {heart_beat, 1}],
      [{node_type, worker}, 
        {dispatcher_port, 5057}, 
        {ccm_nodes, [CCM]}, 
        {dns_port, 1310}, {control_panel_port, 2310}, {control_panel_redirect_port, 1356}, {rest_port, 3310}, {heart_beat, 1}],
      [{node_type, worker}, 
        {dispatcher_port, 5058}, 
        {ccm_nodes, [CCM]}, 
        {dns_port, 1311}, {control_panel_port, 2311}, {control_panel_redirect_port, 1357}, {rest_port, 3311}, {heart_beat, 1}],
      [{node_type, worker}, 
        {dispatcher_port, 5059}, 
        {ccm_nodes, [CCM]}, 
        {dns_port, 1312}, {control_panel_port, 2312}, {control_panel_redirect_port, 1358}, {rest_port, 3312}, {heart_beat, 1}]]),
  
    Assertions = [{false, lists:member(error, Nodes)}, {false, lists:member(error, StartLog)}],
    lists:append([{nodes, Nodes}, {assertions, Assertions}], Config);
  
  
  init_per_testcase(init_and_cleanup_test, Config) ->
    ?INIT_DIST_TEST,
    nodes_manager:start_deps_for_tester_node(),
  
    Nodes = nodes_manager:start_test_on_nodes(2),
    [CCM | _] = Nodes,
     
    StartLog = nodes_manager:start_app_on_nodes(Nodes, 
      [[{node_type, ccm}, 
        {dispatcher_port, 5055}, 
        {ccm_nodes, [CCM]}, 
        {dns_port, 1308}, {control_panel_port, 2308}, {control_panel_redirect_port, 1354},  {rest_port, 3308}, {initialization_time, 1}, {heart_beat, 1}],
      [{node_type, worker}, 
        {dispatcher_port, 5056}, 
        {ccm_nodes, [CCM]}, 
        {dns_port, 1309}, {control_panel_port, 2309}, {control_panel_redirect_port, 1355},  {rest_port, 3309}, {heart_beat, 1}]]),
  
    Assertions = [{false, lists:member(error, Nodes)}, {false, lists:member(error, StartLog)}],
    lists:append([{nodes, Nodes}, {assertions, Assertions}], Config).
  
  
  end_per_testcase(_, Config) ->
    Nodes = ?config(nodes, Config),
    StopLog = nodes_manager:stop_app_on_nodes(Nodes),
    StopAns = nodes_manager:stop_nodes(Nodes),
    ?assertEqual(false, lists:member(error, StopLog)),
    ?assertEqual(ok, StopAns).
  
negative.code: %% sets up lager traces and if it cleans up after termination
  
  init_and_cleanup_test(Config) ->
      nodes_manager:check_start_assertions(Config),
  
      NodesUp = ?config(nodes, Config),
      [CCM, W] = NodesUp,
  
      % Get standard trace configuration from worker node
      StandardTraces = rpc:call(W, ?MODULE, get_lager_traces, []),
  
      % Init cluster
      gen_server:cast({?Node_Manager_Name, CCM}, do_heart_beat),
      gen_server:cast({global, ?CCM}, {set_monitoring, on}),
      nodes_manager:wait_for_cluster_cast(),
      gen_server:cast({global, ?CCM}, init_cluster),
      nodes_manager:wait_for_cluster_init(),
  
      % Test logger's console loglevel switching functionalities
      ?assertEqual(ok, rpc:call(W, ?MODULE, check_console_loglevel_functionalities, [])),
      ?assertEqual(ok, rpc:call(CCM, ?MODULE, check_console_loglevel_functionalities, [])),
  
      % Get new trace configuration after start of central_logger module
      NewTraces = rpc:call(W, ?MODULE, get_lager_traces, []),
  
      % Check if new configuration contains standard entries plus global log files
      lists:foreach(
          fun(Trace) ->
              ?assert(lists:member(Trace, NewTraces))
          end, StandardTraces),
      ?assert(lists:member({lager_file_backend, "log/global_error.log"}, NewTraces)),
      ?assert(lists:member({lager_file_backend, "log/global_info.log"}, NewTraces)),
      ?assert(lists:member({lager_file_backend, "log/global_debug.log"}, NewTraces)),
      ?assert(lists:member({lager_file_backend, "log/client_error.log"}, NewTraces)),
      ?assert(lists:member({lager_file_backend, "log/client_info.log"}, NewTraces)),
      ?assert(lists:member({lager_file_backend, "log/client_debug.log"}, NewTraces)),
      % And only those
      ?assertEqual(length(StandardTraces) + 6, length(NewTraces)),
  
      % Terminate central_logger worker
      gen_server:cast({global, ?CCM}, {stop_worker, W, central_logger}),
      nodes_manager:wait_for_cluster_cast(),
  
      % Check if traces were reset to default
      TracesAfterCleanup = rpc:call(W, ?MODULE, get_lager_traces, []),
      ?assertEqual(StandardTraces, TracesAfterCleanup),
  
      % Check if lager still works at worker node
      ?assertEqual(ok, rpc:call(W, lager, log, [info, [], "log"])).
  
  
  %% ====================================================
  