~ubuntu-branches/ubuntu/trusty/uwsgi/trusty

« back to all changes in this revision

Viewing changes to plugins/logsocket/logsocket_plugin.c

  • Committer: Package Import Robot
  • Author(s): Janos Guljas
  • Date: 2012-02-13 03:43:28 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20120213034328-d02hz8m5pon6kaxf
Tags: 1.0.3+dfsg-1
* New upstream version.
* Adjust rack plugin LD_RUN_PATH patch.
* Adjust patch for uWSGI Control Center jQuery links in templates.
* Remove '-fno-strict-aliasing' CFLAG patch as it is implemented upstream.
* Remove fix indentation of uwsgidecorators_py patch as implemented upstream.
* Adjust init scripts to use top-bottom options order, as --inherit option
  is not working as in earlier versions. 
* Update debian/copyright file.
* Add LSB Description field to debian/uwsgi.init.d.
* Set Architecture to "all" for binary package uwsgi-extra because
  it contains no architecture dependent files.
* Change uwsgi description. (Closes: #640698)
* New binary packages:
  - uwsgi-plugin-carbon
  - uwsgi-plugin-graylog2
  - uwsgi-plugin-logsocket
  - uwsgi-plugin-probeconnect
  - uwsgi-plugin-probepg
  - uwsgi-plugin-rrdtool
  - uwsgi-plugin-rsyslog
  - uwsgi-plugin-signal
  - uwsgi-plugin-symcall
  - uwsgi-plugin-syslog
* python-uwsgidecorators:
  - fix binary-install rule to call dh_python2
  - remove debian/source.lintian-overrides
* uwsgi-plugin-jvm-openjdk-6:
  - fix FTBFS on armel and powerpc (Closes: #656280)
* uwsgi-plugin-python:
  - document issue "ImportError: No module named site" when using
    virtualenv with Python 2.6 in README.Debian (Closes: #654333)
* Adjust debian/watch uversionmangle option.
* Repack upstram source to remove minimized jQuery and jQuery UI JavaScript
  libraries:
  - add get-orig-source rule to debian/rules
  - append +dfsg to upstream version
  - update debian/watch with dversionmangle option

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "../../uwsgi.h"
 
2
 
 
3
extern struct uwsgi_server uwsgi;
 
4
 
 
5
ssize_t uwsgi_socket_logger(struct uwsgi_logger *ul, char *message, size_t len) {
 
6
 
 
7
        int family = AF_UNIX;
 
8
 
 
9
        if (!ul->configured) {
 
10
 
 
11
                char *comma = strchr(uwsgi.choosen_logger_arg, ',');
 
12
                if (comma) {
 
13
                        ul->data = comma+1;
 
14
                        *comma = 0;
 
15
                }
 
16
 
 
17
                char *colon = strchr(uwsgi.choosen_logger_arg, ':');
 
18
                if (colon) {
 
19
                        family = AF_INET;
 
20
                        ul->addr_len = socket_to_in_addr(uwsgi.choosen_logger_arg, colon, 0, &ul->addr.sa_in);
 
21
                }
 
22
                else {
 
23
                        ul->addr_len = socket_to_un_addr(uwsgi.choosen_logger_arg, &ul->addr.sa_un);
 
24
                }
 
25
 
 
26
                ul->fd = socket(family, SOCK_DGRAM, 0);
 
27
                if (ul->fd < 0) {
 
28
                        uwsgi_error_safe("socket()");
 
29
                        exit(1);
 
30
                }
 
31
 
 
32
                memset(&ul->msg, 0, sizeof(struct msghdr));
 
33
 
 
34
                ul->msg.msg_name = &ul->addr;
 
35
                ul->msg.msg_namelen = ul->addr_len;
 
36
                if (ul->data) {
 
37
                        ul->msg.msg_iov = uwsgi_malloc(sizeof(struct iovec) * 2);
 
38
                        ul->msg.msg_iov[0].iov_base = ul->data;
 
39
                        ul->msg.msg_iov[0].iov_len = strlen(ul->data);
 
40
                        ul->msg.msg_iovlen = 2;
 
41
                        ul->count = 1;
 
42
                }
 
43
                else {
 
44
                        ul->msg.msg_iov = uwsgi_malloc(sizeof(struct iovec));
 
45
                        ul->msg.msg_iovlen = 1;
 
46
                }
 
47
 
 
48
                if (comma) {
 
49
                        *comma = ',' ;
 
50
                }
 
51
 
 
52
                ul->configured = 1;
 
53
        }
 
54
 
 
55
        
 
56
        ul->msg.msg_iov[ul->count].iov_base = message;
 
57
        ul->msg.msg_iov[ul->count].iov_len = len;
 
58
 
 
59
        return sendmsg(ul->fd, &ul->msg, 0);
 
60
 
 
61
}
 
62
 
 
63
void uwsgi_logsocket_register() {
 
64
        uwsgi_register_logger("socket", uwsgi_socket_logger);
 
65
}
 
66
 
 
67
int uwsgi_logsocket_init() {
 
68
        return 0;
 
69
}
 
70
 
 
71
struct uwsgi_plugin logsocket_plugin = {
 
72
 
 
73
        .name = "logsocket",
 
74
        .on_load = uwsgi_logsocket_register,
 
75
        .init = uwsgi_logsocket_init
 
76
 
 
77
};
 
78