added logfile commodity plugin

This commit is contained in:
Roberto De Ioris
2012-10-28 19:27:42 +01:00
parent d70c7ceb89
commit c03dcf4617
4 changed files with 40 additions and 2 deletions
+1 -1
View File
@@ -29,7 +29,7 @@ plugins =
bin_name = uwsgi
append_version =
plugin_dir = .
embedded_plugins = %(main_plugin)s, ping, cache, nagios, rrdtool, carbon, rpc, corerouter, fastrouter, http, ugreen, signal, syslog, rsyslog, logsocket, router_uwsgi, router_redirect, router_basicauth, zergpool, redislog, mongodblog, router_rewrite, router_http
embedded_plugins = %(main_plugin)s, ping, cache, nagios, rrdtool, carbon, rpc, corerouter, fastrouter, http, ugreen, signal, syslog, rsyslog, logsocket, router_uwsgi, router_redirect, router_basicauth, zergpool, redislog, mongodblog, router_rewrite, router_http, logfile
as_shared_library = false
locking = auto
+31
View File
@@ -0,0 +1,31 @@
#include "../../uwsgi.h"
ssize_t uwsgi_file_logger(struct uwsgi_logger *ul, char *message, size_t len) {
if (!ul->configured) {
if (ul->arg) {
ul->fd = open(ul->arg, O_RDWR | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR | S_IRGRP);
if (ul->fd >= 0) {
ul->configured = 1;
}
}
}
if (ul->fd >= 0) {
return write(ul->fd, message, len);
}
return 0;
}
void uwsgi_file_logger_register() {
uwsgi_register_logger("file", uwsgi_file_logger);
}
struct uwsgi_plugin logfile_plugin = {
.name = "logfile",
.on_load = uwsgi_file_logger_register,
};
+6
View File
@@ -0,0 +1,6 @@
NAME='logfile'
CFLAGS = []
LDFLAGS = []
LIBS = []
GCC_LIST = ['logfile']
+2 -1
View File
@@ -15,8 +15,9 @@ ssize_t uwsgi_systemd_logger(struct uwsgi_logger *ul, char *message, size_t len)
}
}
// last \n is missing...
if (base < message+len) {
sd_journal_print(LOG_INFO, base);
sd_journal_print(LOG_INFO, "%.*s", (message+len) - base, base);
}
return 0;