libspf2 1.2.11
spf_log_syslog.c
Go to the documentation of this file.
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of either:
4 *
5 * a) The GNU Lesser General Public License as published by the Free
6 * Software Foundation; either version 2.1, or (at your option) any
7 * later version,
8 *
9 * OR
10 *
11 * b) The two-clause BSD license.
12 *
13 * These licenses can be found with the distribution in the file LICENSES
14 */
15
16
17#include "spf_sys_config.h"
18
19
20#ifdef STDC_HEADERS
21# include <stdio.h>
22# include <stdlib.h> /* malloc / free */
23#endif
24
25#ifdef HAVE_SYSLOG_H
26
27#include <syslog.h> /* stdin / stdout */
28
29#include "spf.h"
30
37void
38SPF_error_syslog(const char *file, int line, const char *errmsg)
39{
40 char buf[128];
41 if (file) {
42 snprintf(buf, sizeof(buf), "%s:%d", file, line);
43 syslog(LOG_MAIL | LOG_ERR, "%-20s %s", buf, errmsg);
44 }
45 else {
46 syslog(LOG_MAIL | LOG_ERR, "%s", errmsg);
47 }
48 abort();
49}
50
51void
52SPF_warning_syslog(const char *file, int line, const char *errmsg)
53{
54 char buf[128];
55 if (file) {
56 snprintf(buf, sizeof(buf), "%s:%d", file, line);
57 syslog(LOG_MAIL | LOG_WARNING, "%-20s %s", buf, errmsg);
58 }
59 else {
60 syslog(LOG_MAIL | LOG_WARNING, "%s", errmsg);
61 }
62}
63
64void
65SPF_info_syslog(const char *file __attribute__ ((unused)), int line __attribute__ ((unused)), const char *errmsg)
66{
67 syslog(LOG_MAIL | LOG_INFO, "%s", errmsg);
68}
69
70void
71SPF_debug_syslog(const char *file, int line, const char *errmsg)
72{
73 char buf[128] = "";
74 if (file) {
75 snprintf(buf, sizeof(buf), "%s:%d", file, line);
76 syslog(LOG_MAIL | LOG_DEBUG, "%-20s %s", buf, errmsg);
77 }
78 else {
79 syslog(LOG_MAIL | LOG_DEBUG, "%s", errmsg);
80 }
81}
82
83#endif
#define __attribute__(x)
Definition spf.h:17
void SPF_debug_syslog(const char *file, int line, const char *errmsg)
void SPF_warning_syslog(const char *file, int line, const char *errmsg)
void SPF_info_syslog(const char *file __attribute__((unused)), int line __attribute__((unused)), const char *errmsg)
void SPF_error_syslog(const char *file, int line, const char *errmsg) __attribute__((noreturn))