~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/syslog/wrap.cc

  • Committer: lbieber
  • Date: 2010-10-01 12:16:18 UTC
  • mfrom: (1802.1.1 fix-bug-651256)
  • Revision ID: lbieber@orisndriz08-20101001121618-uqcboygpjwbiglem
Merge Vijay - fix bug 651256 - Remove --help-extended

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