32
32
#define MAXFQDNLEN 255
33
33
#endif
34
34
35
+ static fcgi_logger flog ;
36
+
35
37
#ifdef _WIN32
36
38
37
39
#include <windows.h>
@@ -407,6 +409,10 @@ void fcgi_terminate(void)
407
409
in_shutdown = 1 ;
408
410
}
409
411
412
+ void fcgi_set_logger (fcgi_logger logger ) {
413
+ flog = logger ;
414
+ }
415
+
410
416
int fcgi_init (void )
411
417
{
412
418
if (!is_initialized ) {
@@ -626,10 +632,10 @@ int fcgi_listen(const char *path, int backlog)
626
632
hep = gethostbyname (host );
627
633
}
628
634
if (!hep || hep -> h_addrtype != AF_INET || !hep -> h_addr_list [0 ]) {
629
- fprintf ( stderr , "Cannot resolve host name '%s'!\n" , host );
635
+ flog ( FCGI_ERROR , "Cannot resolve host name '%s'!\n" , host );
630
636
return -1 ;
631
637
} else if (hep -> h_addr_list [1 ]) {
632
- fprintf ( stderr , "Host '%s' has multiple addresses. You must choose one explicitly!\n" , host );
638
+ flog ( FCGI_ERROR , "Host '%s' has multiple addresses. You must choose one explicitly!\n" , host );
633
639
return -1 ;
634
640
}
635
641
sa .sa_inet .sin_addr .s_addr = ((struct in_addr * )hep -> h_addr_list [0 ])-> s_addr ;
@@ -666,7 +672,7 @@ int fcgi_listen(const char *path, int backlog)
666
672
int path_len = strlen (path );
667
673
668
674
if (path_len >= sizeof (sa .sa_unix .sun_path )) {
669
- fprintf ( stderr , "Listening socket's path name is too long.\n" );
675
+ flog ( FCGI_ERROR , "Listening socket's path name is too long.\n" );
670
676
return -1 ;
671
677
}
672
678
@@ -689,7 +695,7 @@ int fcgi_listen(const char *path, int backlog)
689
695
bind (listen_socket , (struct sockaddr * ) & sa , sock_len ) < 0 ||
690
696
listen (listen_socket , backlog ) < 0 ) {
691
697
692
- fprintf ( stderr , "Cannot bind/listen socket - [%d] %s.\n" ,errno , strerror (errno ));
698
+ flog ( FCGI_ERROR , "Cannot bind/listen socket - [%d] %s.\n" ,errno , strerror (errno ));
693
699
return -1 ;
694
700
}
695
701
@@ -719,7 +725,7 @@ int fcgi_listen(const char *path, int backlog)
719
725
}
720
726
allowed_clients [n ] = inet_addr (cur );
721
727
if (allowed_clients [n ] == INADDR_NONE ) {
722
- fprintf ( stderr , "Wrong IP address '%s' in FCGI_WEB_SERVER_ADDRS\n" , cur );
728
+ flog ( FCGI_ERROR , "Wrong IP address '%s' in FCGI_WEB_SERVER_ADDRS\n" , cur );
723
729
}
724
730
n ++ ;
725
731
cur = end ;
@@ -1229,7 +1235,7 @@ int fcgi_accept_request(fcgi_request *req)
1229
1235
n ++ ;
1230
1236
}
1231
1237
if (!allowed ) {
1232
- fprintf ( stderr , "Connection from disallowed IP address '%s' is dropped.\n" , inet_ntoa (sa .sa_inet .sin_addr ));
1238
+ flog ( FCGI_ERROR , "Connection from disallowed IP address '%s' is dropped.\n" , inet_ntoa (sa .sa_inet .sin_addr ));
1233
1239
closesocket (req -> fd );
1234
1240
req -> fd = -1 ;
1235
1241
continue ;
@@ -1287,7 +1293,7 @@ int fcgi_accept_request(fcgi_request *req)
1287
1293
}
1288
1294
fcgi_close (req , 1 , 0 );
1289
1295
} else {
1290
- fprintf ( stderr , "Too many open file descriptors. FD_SETSIZE limit exceeded." );
1296
+ flog ( FCGI_ERROR , "Too many open file descriptors. FD_SETSIZE limit exceeded." );
1291
1297
fcgi_close (req , 1 , 0 );
1292
1298
}
1293
1299
#endif
0 commit comments