21 static VALUE mSyslogConstants;
23 static VALUE mSyslogOption;
25 static VALUE mSyslogFacility;
27 static VALUE mSyslogLevel;
29 static VALUE mSyslogMacros;
31 static const char *syslog_ident =
NULL;
32 static int syslog_options = -1, syslog_facility = -1, syslog_mask = -1;
33 static int syslog_opened = 0;
64 xfree((
void *)syslog_ident);
66 syslog_options = syslog_facility = syslog_mask = -1;
152 VALUE ident, opt, fac;
153 const char *ident_ptr;
166 syslog_ident =
strdup(ident_ptr);
169 syslog_options = LOG_PID | LOG_CONS;
175 syslog_facility = LOG_USER;
177 syslog_facility =
NUM2INT(fac);
180 openlog(syslog_ident, syslog_options, syslog_facility);
184 setlogmask(syslog_mask = setlogmask(0));
207 return mSyslog_open(argc, argv,
self);
231 return syslog_opened ?
INT2NUM(syslog_options) :
Qnil;
238 return syslog_opened ?
INT2NUM(syslog_facility) :
Qnil;
246 return syslog_opened ?
INT2NUM(syslog_mask) :
Qnil;
266 if (!syslog_opened) {
270 setlogmask(syslog_mask =
NUM2INT(mask));
318 syslog_write(
FIX2INT(pri), argc, argv);
332 return rb_sprintf(
"<#%"PRIsVALUE": opened=true, ident=\"%s\", options=%d, facility=%d, mask=%d>",
347 #define define_syslog_shortcut_method(pri, name) \ 348 static VALUE mSyslog_##name(int argc, VALUE *argv, VALUE self) \ 350 syslog_write((pri), argc, argv); \ 451 #define rb_define_syslog_option(c) \ 452 rb_define_const(mSyslogOption, #c, INT2NUM(c)) 475 #define rb_define_syslog_facility(c) \ 476 rb_define_const(mSyslogFacility, #c, INT2NUM(c)) 550 #define rb_define_syslog_level(c, m) \ 551 rb_define_const(mSyslogLevel, #c, INT2NUM(c)); \ 552 rb_define_module_function(mSyslog, #m, mSyslog_##m, -1) #define rb_define_syslog_facility(c)
void rb_define_singleton_method(VALUE obj, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a singleton method for obj.
int rb_block_given_p(void)
Determines if the current method is given a block.
VALUE rb_f_sprintf(int, const VALUE *)
void rb_raise(VALUE exc, const char *fmt,...)
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
void rb_include_module(VALUE klass, VALUE module)
VALUE rb_ensure(VALUE(*b_proc)(ANYARGS), VALUE data1, VALUE(*e_proc)(ANYARGS), VALUE data2)
An equivalent to ensure clause.
VALUE rb_obj_class(VALUE)
call-seq: obj.class -> class
VALUE rb_gv_get(const char *)
void rb_define_module_function(VALUE module, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a module function for module.
VALUE rb_sprintf(const char *format,...)
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
VALUE rb_define_module_under(VALUE outer, const char *name)
#define StringValueCStr(v)
#define rb_define_syslog_option(c)
#define UNLIMITED_ARGUMENTS
#define rb_define_syslog_level(c, m)
void rb_extend_object(VALUE obj, VALUE module)
Extend the object with the module.
void rb_check_safe_obj(VALUE)
VALUE rb_define_module(const char *name)
#define define_syslog_shortcut_method(pri, name)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)