~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/syslog/errmsg.cc

  • Committer: Lee Bieber
  • Date: 2010-12-05 19:04:34 UTC
  • mfrom: (1975.1.4 build)
  • Revision ID: kalebral@gmail.com-20101205190434-9mtyc2cfzbd1hbye
Merge Padraig - Fix for query rewrite plugin.
Merge Monty: more plugin_sysvar removal work.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include "errmsg.h"
28
28
#include "wrap.h"
29
29
 
30
 
using namespace drizzled;
31
 
 
32
 
ErrorMessage_syslog::ErrorMessage_syslog()
33
 
  : drizzled::plugin::ErrorMessage("ErrorMessage_syslog")
34
 
{
35
 
  syslog_facility= WrapSyslog::getFacilityByName(syslog_module::sysvar_facility);
36
 
  if (syslog_facility == -1)
37
 
  {
38
 
    errmsg_printf(ERRMSG_LVL_WARN,
39
 
                  _("syslog facility \"%s\" not known, using \"local0\""),
40
 
                  syslog_module::sysvar_facility);
41
 
    syslog_facility= WrapSyslog::getFacilityByName("local0");
42
 
    assert (! (syslog_facility == -1));
43
 
  }
44
 
 
45
 
  syslog_priority= WrapSyslog::getPriorityByName(syslog_module::sysvar_errmsg_priority);
46
 
  if (syslog_priority == -1)
47
 
  {
48
 
    errmsg_printf(ERRMSG_LVL_WARN,
49
 
                  _("syslog priority \"%s\" not known, using \"warn\""),
50
 
                  syslog_module::sysvar_errmsg_priority);
51
 
    syslog_priority= WrapSyslog::getPriorityByName("warn");
52
 
    assert (! (syslog_priority == -1));
53
 
  }
54
 
 
55
 
  WrapSyslog::singleton().openlog(syslog_module::sysvar_ident);
 
30
namespace drizzle_plugin
 
31
{
 
32
 
 
33
error_message::Syslog::Syslog(const std::string& facility,
 
34
                              const std::string& priority) :
 
35
  drizzled::plugin::ErrorMessage("Syslog"),
 
36
  _facility(WrapSyslog::getFacilityByName(facility.c_str())),
 
37
  _priority(WrapSyslog::getPriorityByName(priority.c_str()))
 
38
{
 
39
  if (_facility == -1)
 
40
  {
 
41
    drizzled::errmsg_printf(ERRMSG_LVL_WARN,
 
42
                            _("syslog facility \"%s\" not known, using \"local0\""),
 
43
                            facility.c_str());
 
44
    _facility= WrapSyslog::getFacilityByName("local0");
 
45
  }
 
46
 
 
47
  if (_priority == -1)
 
48
  {
 
49
    drizzled::errmsg_printf(ERRMSG_LVL_WARN,
 
50
                            _("syslog priority \"%s\" not known, using \"warn\""),
 
51
                            priority.c_str());
 
52
    _priority= WrapSyslog::getPriorityByName("warn");
 
53
  }
56
54
}
57
55
 
58
 
bool ErrorMessage_syslog::errmsg(drizzled::Session *,
59
 
                                 int,
60
 
                                 const char *format, va_list ap)
 
56
bool error_message::Syslog::errmsg(drizzled::Session *,
 
57
                                  int, const char *format, va_list ap)
61
58
{
62
 
  if (syslog_module::sysvar_errmsg_enable == false)
63
 
    return false;
64
 
  WrapSyslog::singleton().vlog(syslog_facility, syslog_priority, format, ap);
 
59
  WrapSyslog::singleton().vlog(_facility, _priority, format, ap);
65
60
  return false;
66
61
}
 
62
 
 
63
} /* namespace drizzle_plugin */