~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/syslog/wrap.cc

  • Committer: lbieber at stabletransit
  • Date: 2010-10-19 14:03:27 UTC
  • mfrom: (1861.1.2 build)
  • Revision ID: lbieber@drizzle-build-n02.wc1.dfw1.stabletransit.com-20101019140327-2jvt5j2wi4pzhm1z
Merge Brian - Small collection of cleanups/refactor'ing around locks
Merge Monty - fix a few things in the tarball

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
# include <syslog.h>
32
32
#endif
33
33
 
34
 
namespace drizzle_plugin
35
 
{
36
 
 
37
34
WrapSyslog::WrapSyslog () :
38
 
  _check(false)
 
35
  openlog_check(false)
39
36
{ }
40
37
 
41
38
WrapSyslog::~WrapSyslog ()
43
40
  ::closelog();
44
41
}
45
42
 
 
43
WrapSyslog& WrapSyslog::singleton()
 
44
{
 
45
  static WrapSyslog handle;
 
46
  return handle;
 
47
}
46
48
 
47
49
/* TODO, for the sake of performance, scan through all the priority
48
50
   and facility names, and construct a stl hash, minimal perfect hash,
75
77
  return -1;
76
78
}
77
79
 
78
 
void WrapSyslog::openlog(const std::string &ident)
 
80
void WrapSyslog::openlog(char *ident)
79
81
{
80
 
  if (_check == false)
 
82
  if (openlog_check == false)
81
83
  {
82
 
    ::openlog(ident.c_str(), LOG_PID, LOG_USER);
83
 
    _check= true;
 
84
    memset(openlog_ident, 0, sizeof(openlog_ident));
 
85
    strncpy(openlog_ident, ident, sizeof(openlog_ident)-1);
 
86
    ::openlog(openlog_ident, LOG_PID, LOG_USER);
 
87
    openlog_check= true;
84
88
  }
85
89
}
86
90
 
87
91
void WrapSyslog::vlog(int facility, int priority, const char *format, va_list ap)
88
92
{
89
 
  assert(_check == true);
 
93
  assert(openlog_check == true);
90
94
  vsyslog(facility | priority, format, ap);
91
95
}
92
96
 
93
97
void WrapSyslog::log (int facility, int priority, const char *format, ...)
94
98
{
95
 
  assert(_check == true);
 
99
  assert(openlog_check == true);
96
100
  va_list ap;
97
101
  va_start(ap, format);
98
102
  vsyslog(facility | priority, format, ap);
99
103
  va_end(ap);
100
104
}
101
 
 
102
 
} /* namespace drizzle_plugin */