~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to plugin/syslog/errmsg.cc

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-12-09 06:02:39 UTC
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: james.westby@ubuntu.com-20101209060239-t0ujftvcvd558yno
Tags: upstream-2010.12.05
ImportĀ upstreamĀ versionĀ 2010.12.05

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 */