]> git.pld-linux.org Git - packages/pound.git/blob - pound-logfile.patch
- add ErrorLog directive
[packages/pound.git] / pound-logfile.patch
1 --- Pound-2.4.3/config.c        2008-12-11 00:55:24.275734964 +0200
2 +++ Pound-2.4.3-logfile/config.c        2008-12-11 00:22:22.509353295 +0200
3 @@ -72,7 +72,7 @@
4  };
5  #endif
6  
7 -static regex_t  Empty, Comment, User, Group, RootJail, Daemon, LogFacility, LogLevel, Alive, SSLEngine, Control;
8 +static regex_t  Empty, Comment, User, Group, RootJail, Daemon, LogFacility, LogFile, LogLevel, Alive, SSLEngine, Control;
9  static regex_t  ListenHTTP, ListenHTTPS, End, Address, Port, Cert, xHTTP, Client, CheckURL;
10  static regex_t  Err414, Err500, Err501, Err503, MaxRequest, HeadRemove, RewriteLocation, RewriteDestination;
11  static regex_t  Service, ServiceName, URL, HeadRequire, HeadDeny, BackEnd, Emergency, Priority, HAport, HAportAddr;
12 @@ -1104,6 +1104,14 @@
13                          def_facility = facilitynames[i].c_val;
14                          break;
15                      }
16 +        } else if(!regexec(&LogFile, lin, 4, matches, 0)) {
17 +            lin[matches[1].rm_eo] = '\0';
18 +            if((log_file = strdup(lin + matches[1].rm_so)) == NULL) {
19 +                logmsg(LOG_ERR, "line %d: LogFile config: out of memory - aborted", n_lin);
20 +                exit(1);
21 +            }
22 +           // force facility to log stdout internally.
23 +           def_facility = -1;
24          } else if(!regexec(&Grace, lin, 4, matches, 0)) {
25              grace = atoi(lin + matches[1].rm_so);
26          } else if(!regexec(&LogLevel, lin, 4, matches, 0)) {
27 @@ -1204,6 +1212,7 @@
28      || regcomp(&RootJail, "^[ \t]*RootJail[ \t]+\"(.+)\"[ \t]*$", REG_ICASE | REG_NEWLINE | REG_EXTENDED)
29      || regcomp(&Daemon, "^[ \t]*Daemon[ \t]+([01])[ \t]*$", REG_ICASE | REG_NEWLINE | REG_EXTENDED)
30      || regcomp(&LogFacility, "^[ \t]*LogFacility[ \t]+([a-z0-9-]+)[ \t]*$", REG_ICASE | REG_NEWLINE | REG_EXTENDED)
31 +    || regcomp(&LogFile, "^[ \t]*LogFile[ \t]+(.+)[ \t]*$", REG_ICASE | REG_NEWLINE | REG_EXTENDED)
32      || regcomp(&LogLevel, "^[ \t]*LogLevel[ \t]+([0-5])[ \t]*$", REG_ICASE | REG_NEWLINE | REG_EXTENDED)
33      || regcomp(&Grace, "^[ \t]*Grace[ \t]+([0-9]+)[ \t]*$", REG_ICASE | REG_NEWLINE | REG_EXTENDED)
34      || regcomp(&Alive, "^[ \t]*Alive[ \t]+([1-9][0-9]*)[ \t]*$", REG_ICASE | REG_NEWLINE | REG_EXTENDED)
35 @@ -1329,6 +1338,7 @@
36      group = NULL;
37      root_jail = NULL;
38      ctrl_name = NULL;
39 +    log_file = NULL;
40  
41      alive_to = 30;
42      daemonize = 1;
43 @@ -1358,6 +1368,7 @@
44      regfree(&RootJail);
45      regfree(&Daemon);
46      regfree(&LogFacility);
47 +    regfree(&LogFile);
48      regfree(&LogLevel);
49      regfree(&Grace);
50      regfree(&Alive);
51 --- Pound-2.4.3-logfile/pound.c 2008-12-11 00:51:21.169092412 +0200
52 +++ Pound-2.4.3.logs/pound.c    2009-01-08 18:03:00.316961385 +0200
53 @@ -33,6 +33,8 @@
54              *group,             /* group to run as */
55              *root_jail,         /* directory to chroot to */
56              *pid_name,          /* file to record pid in */
57 +            *log_file,          /* print log messages to this file, instead of syslog */
58 +            *error_log,         /* print error messages to this file, instead of syslog */
59              *ctrl_name;         /* control socket name */
60  
61  int         alive_to,           /* check interval for resurrection */
62 @@ -289,10 +291,22 @@
63          /* daemonize - make ourselves a subprocess. */
64          switch (fork()) {
65              case 0:
66 -                if(log_facility != -1) {
67 -                    close(0);
68 -                    close(1);
69 -                    close(2);
70 +                close(0);
71 +                if (log_file) {
72 +                    stdout = freopen(log_file, "a", stdout);
73 +                    setlinebuf(stdout);
74 +                } else {
75 +                    if (log_facility != -1) {
76 +                        close(1);
77 +                    }
78 +                }
79 +                if (error_log) {
80 +                    stderr = freopen(error_log, "a", stderr);
81 +                    setlinebuf(stderr);
82 +                } else {
83 +                    if (log_facility != -1) {
84 +                        close(2);
85 +                    }
86                  }
87                  break;
88              case -1:
89 --- Pound-2.4.3-logfile/pound.h 2008-12-11 00:16:43.449299956 +0200
90 +++ Pound-2.4.3.logs/pound.h    2009-01-08 17:47:38.940178535 +0200
91 @@ -236,6 +236,8 @@
92              *group,             /* group to run as */
93              *root_jail,         /* directory to chroot to */
94              *pid_name,          /* file to record pid in */
95 +            *log_file,          /* print log messages to this file, instead of syslog */
96 +            *error_log,         /* print error messages to this file, instead of syslog */
97              *ctrl_name;         /* control socket name */
98  
99  extern int  alive_to,           /* check interval for resurrection */
100 --- Pound-2.4.3/svc.c   2009-01-08 18:20:02.970625040 +0200
101 +++ Pound-2.4.3.logs/svc.c      2009-01-08 18:16:21.407506564 +0200
102 @@ -176,13 +176,25 @@
103      char    buf[MAXBUF + 1];
104      va_list ap;
105      struct tm   *t_now, t_res;
106 +    int log = (priority == LOG_INFO || priority == LOG_DEBUG);
107  
108      buf[MAXBUF] = '\0';
109      va_start(ap, fmt);
110      vsnprintf(buf, MAXBUF, fmt, ap);
111      va_end(ap);
112 -    if(log_facility == -1) {
113 -        fprintf((priority == LOG_INFO || priority == LOG_DEBUG)? stdout: stderr, "%s\n", buf);
114 +
115 +    // if access log or error log are set, use them.
116 +    if (log && log_file) {
117 +        printf("%s\n", buf);
118 +        fprintf(stdout, "%s\n", buf);
119 +        return;
120 +    }
121 +    if (!log && error_log) {
122 +        fprintf(stderr, "%s\n", buf);
123 +    }
124 +
125 +    if (log_facility == -1) {
126 +        fprintf(log ? stdout : stderr, "%s\n", buf);
127      } else {
128          if(print_log)
129              printf("%s\n", buf);
This page took 0.059453 seconds and 3 git commands to generate.