anchor.diff:  	{error, E} ->
   	    erlang:fault("Error opening logfile", [Filename, Args])
       end.
  -
  -debug_level(debug) -> 10;
  -debug_level(normal) -> 20;
  -debug_level(error) -> 30.
   
   log_to_device(IoDevice, Level, TimeStamp, Format, Arguments, Pid) ->
       io:format(IoDevice, "~s ~p~p:", [TimeStamp, Level, Pid]),
  
positive.code: %%          {stop, Reason, State}            (terminate/2 is called)
  %%--------------------------------------------------------------------
  handle_cast({log, Level, TimeStamp, Format, Arguments, Pid}, State) ->
      DebugLevel = debug_level(debug),
      NormalLevel = debug_level(normal),
      ErrorLevel = debug_level(error),
      NumLevel = debug_level(Level),
      if
  	NumLevel >= ErrorLevel ->
  	    log_to_stdout(Level, TimeStamp, Format, Arguments, Pid),
  	    log_to_device(State#state.error_iodev, Level, TimeStamp, Format, Arguments, Pid);
  	true -> none
      end,
      if
  	NumLevel >= NormalLevel ->
  	    log_to_device(State#state.normal_iodev, Level, TimeStamp, Format, Arguments, Pid),
  	    %% Make sure we don't log errors twice to stdout
  	    if
  		NumLevel =< NormalLevel ->
  		    log_to_stdout(Level, TimeStamp, Format, Arguments, Pid);
  		true -> none
  	    end;
  	true -> none
      end,
      if
  	NumLevel >= DebugLevel ->
  	    log_to_device(State#state.debug_iodev, Level, TimeStamp, Format, Arguments, Pid);
  	true -> none
      end,
      {noreply, State};
  
  
negative.code: %% persistent logger process.
  do_log(Level, Format, Arguments) when atom(Level), list(Format), list(Arguments) ->
      {Megasec, Sec, USec} = now(),
      USecStr = format_usec(USec, 3),
      DateTime = util:sec_to_date(Megasec * 1000000 + Sec),
      LogTS = lists:concat([DateTime, ".", USecStr]),
      gen_server:cast(logger, {log, Level, LogTS, Format, Arguments, self()}),
      ok.
  
  %% Precision = integer(),range = 1 - 6
  format_usec(Usec, Precision) ->
      Str = integer_to_list(Usec),
      FullStr = string:right(Str, 6, $0), % pad left side with 0, to full 6 char length
      string:substr(FullStr, 1 , Precision).
  
  %%--------------------------------------------------------------------
  %%% Interface functions
  