anchor.diff:              maybe_arm_flush_timer(NewState)
       end.
   
  -flush_buffer(#state{file = File,
  -                    buffer = Buffer,
  -                    buffer_size = BufferSize} = State) ->
  +flush_buffer(State) ->
  +    NewState = do_flush_buffer(State),
  +    maybe_rotate_files(NewState).
  +
  +do_flush_buffer(#state{file = File,
  +                       file_size = FileSize,
  +                       buffer = Buffer,
  +                       buffer_size = BufferSize} = State) ->
       case BufferSize =:= 0 of
           true ->
               State;
           false ->
               ok = file:write(File, Buffer),
  -            NewState = State#state{buffer = <<>>,
  +            NewState = State#state{file_size = FileSize + BufferSize,
  +                                   buffer = <<>>,
                                      buffer_size = 0},
               cancel_flush_timer(NewState)
       end.
  
positive.code: 
  init([Path, Opts]) ->
      process_flag(trap_exit, true),
      File = open_log(Path),
  
      BatchSize = proplists:get_value(batch_size, Opts, 524288),
      BatchTimeout = proplists:get_value(batch_timeout, Opts, 1000),
  
      {ok, #state{path = Path,
                  file = File,
                  buffer = <<>>,
                  buffer_size = 0,
                  batch_size = BatchSize,
                  batch_timeout = BatchTimeout}}.
  
  handle_call({log, Msg}, _From, State) ->
      {reply, ok, log_msg(Msg, State)};
  
negative.code:     {ok, State}.
  
  %% internal functions
  log_msg(Msg, #state{buffer = Buffer,
                      buffer_size = BufferSize,
                      batch_size = BatchSize} = State) ->
  