#include <time.h>
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <syslog.h>

#include <dboxpath.h>
#include <config.h>
#include <logf.h>

logft logf;

logft::~logft()
 {
  closelog();
 }

void logft::initialize()
 {
 }

void logft::openlog(const char *program)
 {
  ::openlog(program, LOG_PID, LOG_MAIL);
 }

int logft::printf(const char *module, const char *format, ...)
 {
  va_list arglist;
  char s[10000];

  va_start(arglist, format);
  vsnprintf(s, 10000, format, arglist);
  syslog(LOG_NOTICE, "%s: %s", module, s);
  va_end(arglist);

  return 1;
 }

int logft::fileprintf(const char *filename, 
                      const char *module,
                      const char *format, ...)
 {
  va_list arglist;
  char s[10000];

  va_start(arglist, format);
  vsnprintf(s, 10000, format, arglist);
  syslog(LOG_NOTICE, "%s: %s", module, s);
  va_end(arglist);

  return 1;
 }

void logft::internalerror(const char *module, const char *error)
 {
  fprintf(stderr, "Interner Fehler: %s: %s\r\n", module, error);
  logf.printf(module, "Interner Fehler: %s", error);
  abort();
 }


syntax highlighted by Code2HTML, v. 0.9.1