|
@@ -122,10 +122,7 @@ int vpyfcgi_log(loglvl_t lvl, const char *fmt, va_list ap)
|
122
|
122
|
|
123
|
123
|
conf = &PyFCGI_conf.logs;
|
124
|
124
|
|
125
|
|
- if(conf->flags & PYFCGI_LOG_FSYSLOG)
|
126
|
|
- {
|
127
|
|
- vsyslog(SYSLOG_LVLS[(lvl & 0xF0) >> 4], fmt, ap);
|
128
|
|
- }
|
|
125
|
+ _vsyslog(lvl, fmt, ap);
|
129
|
126
|
|
130
|
127
|
len = 0;
|
131
|
128
|
if(conf->format_sz > 1)
|
|
@@ -133,12 +130,9 @@ int vpyfcgi_log(loglvl_t lvl, const char *fmt, va_list ap)
|
133
|
130
|
len = vdprintf(conf->pipes[1], fmt, ap);
|
134
|
131
|
if(len < 0)
|
135
|
132
|
{
|
136
|
|
- if(conf->flags & PYFCGI_LOG_FSYSLOG)
|
137
|
|
- {
|
138
|
|
- syslog(SYSLOG_ALERT,
|
139
|
|
- "Unable to write to multiplexer pipe when trying to log : %s",
|
140
|
|
- strerror(errno));
|
141
|
|
- }
|
|
133
|
+ _syslog(LOG_ALERT,
|
|
134
|
+ "Unable to write to multiplexer pipe when trying to log : %s",
|
|
135
|
+ strerror(errno));
|
142
|
136
|
return PYFCGI_FATAL;
|
143
|
137
|
}
|
144
|
138
|
}
|
|
@@ -147,12 +141,9 @@ int vpyfcgi_log(loglvl_t lvl, const char *fmt, va_list ap)
|
147
|
141
|
len = vdprintf(conf->loggers[0].fd, fmt, ap);
|
148
|
142
|
if(len < 0)
|
149
|
143
|
{
|
150
|
|
- if(conf->flags & PYFCGI_LOG_FSYSLOG)
|
151
|
|
- {
|
152
|
|
- syslog(SYSLOG_ALERT,
|
153
|
|
- "Unable to write to single FD to '%s' when trying to log : %s",
|
154
|
|
- conf->loggers[0].filename, strerror(errno));
|
155
|
|
- }
|
|
144
|
+ _syslog(LOG_ALERT,
|
|
145
|
+ "Unable to write to single FD to '%s' when trying to log : %s",
|
|
146
|
+ conf->loggers[0].filename, strerror(errno));
|
156
|
147
|
return PYFCGI_FATAL;
|
157
|
148
|
}
|
158
|
149
|
return 0;
|
|
@@ -162,40 +153,34 @@ int vpyfcgi_log(loglvl_t lvl, const char *fmt, va_list ap)
|
162
|
153
|
ret = tee(conf->pipes[0], conf->loggers[i].fd, len, 0);
|
163
|
154
|
if(ret < 0)
|
164
|
155
|
{
|
165
|
|
- if(conf->flags & PYFCGI_LOG_FSYSLOG)
|
166
|
|
- {
|
167
|
|
- syslog(SYSLOG_ALERT,
|
168
|
|
- "Unable to splice to last logfile '%s' : %s",
|
169
|
|
- conf->loggers[i].filename, strerror(errno));
|
170
|
|
- }
|
|
156
|
+ _syslog(LOG_ALERT,
|
|
157
|
+ "Unable to splice to last logfile '%s' : %s",
|
|
158
|
+ conf->loggers[i].filename, strerror(errno));
|
171
|
159
|
return PYFCGI_FATAL;
|
172
|
160
|
}
|
173
|
161
|
}
|
174
|
162
|
ret = splice(conf->pipes[0], NULL, conf->loggers[i].fd, NULL, len, 0);
|
175
|
163
|
if(ret < 0)
|
176
|
164
|
{
|
177
|
|
- if(conf->flags & PYFCGI_LOG_FSYSLOG)
|
178
|
|
- {
|
179
|
|
- syslog(SYSLOG_ALERT,
|
180
|
|
- "Unable to splice to last logfile '%s' : %s",
|
181
|
|
- conf->loggers[i].filename, strerror(errno));
|
182
|
|
- }
|
|
165
|
+ _syslog(LOG_ALERT,
|
|
166
|
+ "Unable to splice to last logfile '%s' : %s",
|
|
167
|
+ conf->loggers[i].filename, strerror(errno));
|
183
|
168
|
return PYFCGI_ERR;
|
184
|
169
|
}
|
185
|
170
|
if(ret < len)
|
186
|
171
|
{
|
187
|
|
- if(conf->flags & PYFCGI_LOG_FSYSLOG)
|
188
|
|
- {
|
189
|
|
- syslog(SYSLOG_WARNING,
|
190
|
|
- "Unable to splice all data to logfile. Flushing pipe.");
|
191
|
|
- }
|
|
172
|
+ _syslog(LOG_WARNING,
|
|
173
|
+ "Unable to splice all data to logfile. Flushing pipe.");
|
192
|
174
|
|
193
|
175
|
do
|
194
|
176
|
{
|
195
|
177
|
len -= (ret<len)?ret:len;
|
196
|
|
- ret = read(conf->pipes[0], buf, len>512?512:len);
|
|
178
|
+ ret = read(conf->pipes[0], buf, (len>sizeof(buf))?sizeof(buf):len);
|
197
|
179
|
if(ret < 0)
|
198
|
180
|
{
|
|
181
|
+ _syslog(LOG_CRIT,
|
|
182
|
+ "Logger pipe seems broken, unable to flush : %s",
|
|
183
|
+ strerror(errno));
|
199
|
184
|
return PYFCGI_ERR;
|
200
|
185
|
}
|
201
|
186
|
}while(len);
|