Logo Search packages:      
Sourcecode: launchtool version File versions  Download package

Logger.cc

#ifdef HAVE_CONFIG_H
  #include <config.h>
#endif

#include "Logger.h"

using namespace Log;

//
// Logger
//

Logger* Logger::_instance = 0;

00015 Logger* Logger::instance() throw ()
{
      if (! _instance)
            _instance = new Logger();
      return _instance;
}

/*

static enum stderr_state_type stderr_state = Yes;
static bool debug_output = false;

void set_debug(bool val)
{
      debug_output = val;
}

void set_stderr(enum stderr_state_type val)
{
      switch (val)
      {
            case Yes:
                  call_closelog(); break;
            case No:
                  call_openlog(); break;
            case Restricted:
                  call_openlog(); break;
      }
      stderr_state = val;
}

void log_debug(const char* fmt, ...) ATTR_PRINTF(1, 2)
{
      if (debug_output)
      {
            va_list ap;
            va_start(ap, fmt);
            switch (stderr_state)
            {
                  case Yes:
                        //if (isatty(fileno(stderr)))
                        //{
                              vfprintf(stderr, fmt, ap);
                              fputc('\n', stderr);
                        //}
                        break;
                  case No:
                  case Restricted:
                        vsyslog(LOG_DEBUG, fmt, ap);
                        break;
            }
            va_end(ap);
      }
}

void log_info(const char* fmt, ...) ATTR_PRINTF(1, 2)
{
      va_list ap;
      va_start(ap, fmt);
      switch (stderr_state)
      {
            case Yes:
                  //if (isatty(fileno(stderr)))
                  //{
                        vfprintf(stderr, fmt, ap);
                        fputc('\n', stderr);
                  //}
                  break;
            case No:
            case Restricted:
                  vsyslog(LOG_INFO, fmt, ap);
                  break;
      }
      va_end(ap);
}

void log_warn(const char* fmt, ...) ATTR_PRINTF(1, 2)
{
      va_list ap;
      va_start(ap, fmt);
      switch (stderr_state)
      {
            case Yes:
            case Restricted:
                  vfprintf(stderr, fmt, ap);
                  fputc('\n', stderr);
                  break;
            case No:
                  vsyslog(LOG_WARNING, fmt, ap);
                  break;
      }
      va_end(ap);
}

void log_error(const char* fmt, ...) ATTR_PRINTF(1, 2)
{
      va_list ap;
      va_start(ap, fmt);
      switch (stderr_state)
      {
            case Yes:
            case Restricted:
                  vfprintf(stderr, fmt, ap);
                  fputc('\n', stderr);
                  break;
            case No:
                  vsyslog(LOG_ERR, fmt, ap);
                  break;
      }
      va_end(ap);
}

void log_crit(const char* fmt, ...) ATTR_PRINTF(1, 2)
{
      va_list ap;
      va_start(ap, fmt);
      switch (stderr_state)
      {
            case Yes:
            case Restricted:
                  vfprintf(stderr, fmt, ap);
                  fputc('\n', stderr);
                  break;
            case No:
                  vsyslog(LOG_CRIT, fmt, ap);
                  break;
      }
      va_end(ap);
}

*/

// vim:set ts=4 sw=4:

Generated by  Doxygen 1.6.0   Back to index