72 #define MSG_SYSLOG_RECLEN 2000
84 "authpriv", LOG_AUTHPRIV,
108 "security", LOG_SECURITY,
111 "syslog", LOG_SYSLOG,
120 "local0", LOG_LOCAL0,
123 "local1", LOG_LOCAL1,
126 "local2", LOG_LOCAL2,
129 "local3", LOG_LOCAL3,
132 "local4", LOG_LOCAL4,
135 "local5", LOG_LOCAL5,
138 "local6", LOG_LOCAL6,
141 "local7", LOG_LOCAL7,
146 static int syslog_facility;
150 static void msg_syslog_print(
int level,
const char *text)
152 static int log_level[] = {
153 LOG_INFO, LOG_WARNING, LOG_ERR, LOG_CRIT, LOG_CRIT,
155 static char *severity_name[] = {
156 "info",
"warning",
"error",
"fatal",
"panic",
159 if (level < 0 || level >= (
int) (
sizeof(log_level) /
sizeof(log_level[0])))
160 msg_panic(
"msg_syslog_print: invalid severity level: %d", level);
163 syslog(syslog_facility | log_level[level],
"%.*s",
166 syslog(syslog_facility | log_level[level],
"%s: %.*s",
175 static int first_call = 1;
176 extern char **environ;
184 if (unsetenv(
"TZ") < 0) {
189 openlog(name, LOG_NDELAY | logopt, facility);
200 struct facility_list *fnp;
202 for (fnp = facility_list; fnp->
name; ++fnp) {
203 if (!strcmp(fnp->
name, facility_name)) {
219 int main(
int argc,
char **argv)
225 msg_error(
"usage: %s text to be logged", argv[0]);
226 while (--argc && *++argv) {
233 msg_warn(
"dynamic numeric: >%d<", 42);
void msg_error(const char *fmt,...)
NORETURN msg_panic(const char *fmt,...)
void msg_output(MSG_OUTPUT_FN output_fn)
int main(int argc, char **argv)
void msg_warn(const char *fmt,...)
VSTRING * vstring_alloc(ssize_t len)
NORETURN msg_fatal(const char *fmt,...)
void msg_syslog_init(const char *name, int logopt, int facility)
VSTRING * vstring_free(VSTRING *vp)
VSTRING * vstring_strcat(VSTRING *vp, const char *src)
#define MSG_SYSLOG_RECLEN
int msg_syslog_facility(const char *facility_name)