~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/syslog/errmsg.cc

  • Committer: Brian Aker
  • Date: 2010-10-28 17:12:01 UTC
  • mfrom: (1887.1.3 merge)
  • Revision ID: brian@tangent.org-20101028171201-baj6l1bnntn1s4ad
Merge in POTFILES changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#include "config.h"
21
21
 
22
22
#include <drizzled/gettext.h>
23
 
#include <drizzled/errmsg_print.h>
 
23
#include <drizzled/session.h>
24
24
 
25
25
#include <stdarg.h>
26
26
 
27
27
#include "errmsg.h"
28
28
#include "wrap.h"
29
29
 
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(drizzled::error::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(drizzled::error::WARN,
50
 
                            _("syslog priority \"%s\" not known, using \"warn\""),
51
 
                            priority.c_str());
52
 
    _priority= WrapSyslog::getPriorityByName("warn");
53
 
  }
 
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);
54
56
}
55
57
 
56
 
bool error_message::Syslog::errmsg(drizzled::error::level_t, const char *format, va_list ap)
 
58
bool ErrorMessage_syslog::errmsg(drizzled::Session *,
 
59
                                 int,
 
60
                                 const char *format, va_list ap)
57
61
{
58
 
  WrapSyslog::singleton().vlog(_facility, _priority, format, ap);
 
62
  if (syslog_module::sysvar_errmsg_enable == false)
 
63
    return false;
 
64
  WrapSyslog::singleton().vlog(syslog_facility, syslog_priority, format, ap);
59
65
  return false;
60
66
}
61
 
 
62
 
} /* namespace drizzle_plugin */