@@ -13,7 +13,7 @@ use std::slice;
1313
1414use ngx:: core:: { Pool , Status } ;
1515use ngx:: ffi:: {
16- nginx_version, ngx_atoi, ngx_command_t, ngx_conf_log_error , ngx_conf_t, ngx_connection_t, ngx_event_free_peer_pt,
16+ nginx_version, ngx_atoi, ngx_command_t, ngx_conf_t, ngx_connection_t, ngx_event_free_peer_pt,
1717 ngx_event_get_peer_pt, ngx_http_module_t, ngx_http_upstream_init_peer_pt, ngx_http_upstream_init_pt,
1818 ngx_http_upstream_init_round_robin, ngx_http_upstream_module, ngx_http_upstream_srv_conf_t, ngx_http_upstream_t,
1919 ngx_int_t, ngx_module_t, ngx_peer_connection_t, ngx_str_t, ngx_uint_t, NGX_CONF_NOARGS , NGX_CONF_TAKE1 ,
@@ -24,7 +24,10 @@ use ngx::http::{
2424 ngx_http_conf_get_module_srv_conf, ngx_http_conf_upstream_srv_conf_immutable,
2525 ngx_http_conf_upstream_srv_conf_mutable, HTTPModule , Merge , MergeConfigError , Request ,
2626} ;
27- use ngx:: { http_upstream_init_peer_pt, ngx_log_debug_http, ngx_log_debug_mask, ngx_null_command, ngx_string} ;
27+ use ngx:: {
28+ http_upstream_init_peer_pt, ngx_conf_log_error, ngx_log_debug_http, ngx_log_debug_mask, ngx_null_command,
29+ ngx_string,
30+ } ;
2831
2932#[ derive( Clone , Copy , Debug ) ]
3033#[ repr( C ) ]
@@ -242,12 +245,7 @@ unsafe extern "C" fn ngx_http_upstream_init_custom(
242245 let maybe_conf: Option < * mut SrvConfig > =
243246 ngx_http_conf_upstream_srv_conf_mutable ( us, & * addr_of ! ( ngx_http_upstream_custom_module) ) ;
244247 if maybe_conf. is_none ( ) {
245- ngx_conf_log_error (
246- NGX_LOG_EMERG as usize ,
247- cf,
248- 0 ,
249- "CUSTOM UPSTREAM no upstream srv_conf" . as_bytes ( ) . as_ptr ( ) as * const c_char ,
250- ) ;
248+ ngx_conf_log_error ! ( NGX_LOG_EMERG , cf, "CUSTOM UPSTREAM no upstream srv_conf" ) ;
251249 return isize:: from ( Status :: NGX_ERROR ) ;
252250 }
253251 let hccf = maybe_conf. unwrap ( ) ;
@@ -258,12 +256,7 @@ unsafe extern "C" fn ngx_http_upstream_init_custom(
258256
259257 let init_upstream_ptr = ( * hccf) . original_init_upstream . unwrap ( ) ;
260258 if init_upstream_ptr ( cf, us) != Status :: NGX_OK . into ( ) {
261- ngx_conf_log_error (
262- NGX_LOG_EMERG as usize ,
263- cf,
264- 0 ,
265- "CUSTOM UPSTREAM failed calling init_upstream" . as_bytes ( ) . as_ptr ( ) as * const c_char ,
266- ) ;
259+ ngx_conf_log_error ! ( NGX_LOG_EMERG , cf, "CUSTOM UPSTREAM failed calling init_upstream" ) ;
267260 return isize:: from ( Status :: NGX_ERROR ) ;
268261 }
269262
@@ -290,13 +283,12 @@ unsafe extern "C" fn ngx_http_upstream_commands_set_custom(
290283 let value: & [ ngx_str_t ] = slice:: from_raw_parts ( ( * ( * cf) . args ) . elts as * const ngx_str_t , ( * ( * cf) . args ) . nelts ) ;
291284 let n = ngx_atoi ( value[ 1 ] . data , value[ 1 ] . len ) ;
292285 if n == ( NGX_ERROR as isize ) || n == 0 {
293- ngx_conf_log_error (
294- NGX_LOG_EMERG as usize ,
286+ ngx_conf_log_error ! (
287+ NGX_LOG_EMERG ,
295288 cf,
296- 0 ,
297- "invalid value \" %V\" in \" %V\" directive" . as_bytes ( ) . as_ptr ( ) as * const c_char ,
289+ "invalid value \" {}\" in \" {}\" directive" ,
298290 value[ 1 ] ,
299- & ( * cmd) . name ,
291+ & ( * cmd) . name
300292 ) ;
301293 return usize:: MAX as * mut c_char ;
302294 }
@@ -334,13 +326,10 @@ impl HTTPModule for Module {
334326 let mut pool = Pool :: from_ngx_pool ( ( * cf) . pool ) ;
335327 let conf = pool. alloc_type :: < SrvConfig > ( ) ;
336328 if conf. is_null ( ) {
337- ngx_conf_log_error (
338- NGX_LOG_EMERG as usize ,
329+ ngx_conf_log_error ! (
330+ NGX_LOG_EMERG ,
339331 cf,
340- 0 ,
341332 "CUSTOM UPSTREAM could not allocate memory for config"
342- . as_bytes ( )
343- . as_ptr ( ) as * const c_char ,
344333 ) ;
345334 return std:: ptr:: null_mut ( ) ;
346335 }
0 commit comments