let open_files =
  let opened = ref false in
  let openlog f =
    Unix.openfile
      ((Ocsiconfig.get_logdir ())^"/"^f)
      [Unix.O_WRONLYUnix.O_CREATUnix.O_APPEND] 0o640
  in
  fun () ->
    if !opened
    then begin
      Unix.close !(snd access);
      Unix.close !(snd warning);
      Unix.close !(snd error)
    end;
    opened := true;
    snd access := openlog (fst access);
    snd warning := openlog (fst warning);
    snd error := openlog (fst error)