anchor.diff:           open/3,
            log/3,
            log/4,
  -         close/1
  +         close/1,
  +         priority/1,
  +         facility/1,
  +         openlog_opt/1
           ]).
   
   %% gen_server callbacks
  
positive.code:             {error, Reason}
      end.
  
  log(_Log, _Priority, []) ->
      ok;
  log(Log, Priority, Message) ->
      NumPri = priorities(Priority),
      %% encode the priority value as a 4-byte integer in network order, and
      %% add a 0 byte to the end of the command data to act as a NUL character
      true = erlang:port_command(Log, [<<NumPri:32/big>>, Message, <<0:8>>]),
      ok.
  log(Log, Priority, FormatStr, FormatArgs) ->
      log(Log, Priority, io_lib:format(FormatStr, FormatArgs)).
  
  close(Log) ->
      true = erlang:port_close(Log),
      ok.
  
  
  %%% API %%%
  
  init([]) ->
      process_flag(trap_exit, true),
  
negative.code: 
  -record(state, {}).
  
  -type priority() :: emerg | alert | crit | err |
                      warning | notice | info | debug | non_neg_integer().
  -type facility() :: kern | user | mail | daemon | auth | syslog |
                      lpr | news | uucp | cron | authpriv | ftp |
                      netinfo | remoteauth | install | ras |
                      local0 | local1 | local2 | local3 |
                      local4 | local5 | local6 | local7 | non_neg_integer().
  -type openlog_opt() :: pid | cons | odelay | ndelay | perror | pos_integer().
  -export_type([priority/0, facility/0, openlog_opt/0]).
  
  %%% API %%%
  
  -spec start() ->
      {ok, pid()} | ignore | {error, any()}.
  
  start() ->
      gen_server:start({local, ?MODULE}, ?MODULE, [], []).
  
  -spec start_link() ->
      {ok, pid()} | ignore | {error, any()}.
  
  start_link() ->
      gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
  
  -spec stop() ->
      ok.
  
  stop() ->
      gen_server:cast(?MODULE, stop).
  
  -spec open(Ident :: string(),
             Logopt :: list(openlog_opt()),
             Facility :: facility()) ->
      {ok, port()} |
      {error, any()}.
  
  open(Ident, Logopt, Facility) ->
      Log = erlang:open_port({spawn, ?DRV_NAME}, [binary]),
  