anchor.diff:  %% @doc Open an accounting event disk log.
   acct_open() ->
   	{ok, Directory} = application:get_env(ocs, acct_log_dir),
  -	case file:make_dir(Directory) of
  -		ok ->
  -			acct_open1(Directory);
  -		{error, eexist} ->
  -			acct_open1(Directory);
  -		{error, Reason} ->
  -			{error, Reason}
  -	end.
  -%% @hidden
  -acct_open1(Directory) ->
   	{ok, LogSize} = application:get_env(ocs, acct_log_size),
   	{ok, LogFiles} = application:get_env(ocs, acct_log_files),
  -	Log = ?ACCTLOG,
  -	FileName = Directory ++ "/" ++ atom_to_list(Log),
  -	case disk_log:open([{name, Log}, {file, FileName},
  -					{type, wrap}, {size, {LogSize, LogFiles}}]) of
  -		{ok, Log} ->
  -			ok;
  -		{repaired, Log, _Recovered, _Bad} ->
  -			ok;
  -		{error, Reason} ->
  -			Descr = lists:flatten(disk_log:format_error(Reason)),
  -			Trunc = lists:sublist(Descr, length(Descr) - 1),
  -			error_logger:error_report([Trunc, {module, ?MODULE},
  -					{log, Log}, {error, Reason}]),
  -			{error, Reason}
  -	end.
  +	open_log(Directory, ?ACCTLOG, LogSize, LogFiles).
   
   -type acct_event() :: {
   		TS :: pos_integer(), % posix time in milliseconds
  
positive.code: 		Reason :: term().
  %% @doc Close accounting disk log.
  acct_close() ->
  	case disk_log:close(?ACCTLOG) of
  		ok ->
  			ok;
  		{error, Reason} ->
  			Descr = lists:flatten(disk_log:format_error(Reason)),
  			Trunc = lists:sublist(Descr, length(Descr) - 1),
  			error_logger:error_report([Trunc, {module, ?MODULE},
  					{log, ?ACCTLOG}, {error, Reason}]),
  			{error, Reason}
  	end.
  
  -spec acct_query(Continuation, Start, End, Types, AttrsMatch) -> Result
  	when
  
negative.code: 	<<Status:Offset/binary, 32, _Rest/binary>> = Event,
  	Acc#event{httpStatus = binary_to_integer(Status)}.
  
  -spec open_log(Directory, Log, LogSize, LogFiles) -> Result
  	when
  		Directory  :: string(),
  		Log :: atom(),
  		LogSize :: integer(),
  		LogFiles :: integer(),
  		Result :: ok | {error, Reason},
  		Reason :: term().
  %% @doc open disk log file
  open_log(Directory, Log, LogSize, LogFiles) ->
  	case file:make_dir(Directory) of
  		ok ->
  			open_log1(Directory, Log, LogSize, LogFiles);
  		{error, eexist} ->
  			open_log1(Directory, Log, LogSize, LogFiles);
  		{error, Reason} ->
  			{error, Reason}
  	end.
  %% @hidden
  open_log1(Directory, Log, LogSize, LogFiles) ->
  	FileName = Directory ++ "/" ++ atom_to_list(Log),
  	case disk_log:open([{name, Log}, {file, FileName},
  					{type, wrap}, {size, {LogSize, LogFiles}}]) of
  		{ok, Log} ->
  			ok;
  		{repaired, Log, _Recovered, _Bad} ->
  			ok;
  		{error, Reason} ->
  			Descr = lists:flatten(disk_log:format_error(Reason)),
  			Trunc = lists:sublist(Descr, length(Descr) - 1),
  			error_logger:error_report([Trunc, {module, ?MODULE},
  					{log, Log}, {error, Reason}]),
  			{error, Reason}
  	end.
  
  -spec write_log(Log, Event) -> Result
  	when
  		Log :: atom(),
  		Event :: list(),
  		Result :: ok | {error, Reason},
  		Reason :: term().
  %% @doc write event into given log file
  write_log(Log, Event) ->
  	TS = erlang:system_time(?MILLISECOND),
  	N = erlang:unique_integer([positive]),
  	LogEvent = list_to_tuple([TS, N | Event]),
  	disk_log:log(Log, LogEvent).
  
  -spec close_log(Log) -> Result
  	when
  		Log :: atom(),
  		Result :: ok | {error, Reason},
  		Reason :: term().
  %% @doc close log files
  close_log(Log) ->
  	case disk_log:close(Log) of
  		ok ->
  			ok;
  		{error, Reason} ->
  			Descr = lists:flatten(disk_log:format_error(Reason)),
  			Trunc = lists:sublist(Descr, length(Descr) - 1),
  			error_logger:error_report([Trunc, {module, ?MODULE},
  					{log, Log}, {error, Reason}]),
  			{error, Reason}
  	end.
  