@@ -112,14 +112,12 @@ void *oauth2_apache_cfg_srv_create(apr_pool_t *pool, server_rec *s,
112112 (oauth2_apache_cfg_srv_t * )oauth2_mem_alloc (
113113 sizeof (oauth2_apache_cfg_srv_t ));
114114
115- cfg -> sink = oauth2_mem_alloc (sizeof (oauth2_log_sink_t ));
116- cfg -> sink -> callback = server_log_cb ;
117115 // NB: this is not actually set to the/a configured level here...
118- cfg -> sink -> level = (s && (s -> log .level != -1 ))
119- ? log_level_apache2oauth2 [s -> log .level ]
120- : OAUTH2_LOG_TRACE1 ;
121- cfg -> sink -> ctx = s ;
122- cfg -> log = oauth2_log_init (cfg -> sink -> level , cfg -> sink );
116+ oauth2_uint_t level = (s && (s -> log .level != -1 ))
117+ ? log_level_apache2oauth2 [s -> log .level ]
118+ : OAUTH2_LOG_TRACE1 ;
119+ cfg -> sink = oauth2_log_sink_create ( level , server_log_cb , s ) ;
120+ cfg -> log = oauth2_log_init (level , cfg -> sink );
123121
124122 return cfg ;
125123}
@@ -128,7 +126,8 @@ void *oauth2_apache_cfg_srv_merge(apr_pool_t *pool, void *b, void *a)
128126{
129127 oauth2_apache_cfg_srv_t * add = (oauth2_apache_cfg_srv_t * )a ;
130128 oauth2_apache_cfg_srv_t * cfg = oauth2_apache_cfg_srv_create (
131- pool , (server_rec * )add -> sink -> ctx , add -> sink -> callback );
129+ pool , (server_rec * )oauth2_log_sink_ctx_get (add -> sink ),
130+ oauth2_log_sink_ctx_get (add -> sink ));
132131 return cfg ;
133132}
134133
@@ -194,9 +193,10 @@ int oauth2_apache_post_config(apr_pool_t *pool, apr_pool_t *p1, apr_pool_t *p2,
194193 cfg = (oauth2_apache_cfg_srv_t * )ap_get_module_config (
195194 sp -> module_config , m );
196195 // only now the level has been set according to the config!
197- cfg -> sink -> level = (sp && (sp -> log .level != -1 ))
198- ? log_level_apache2oauth2 [sp -> log .level ]
199- : OAUTH2_LOG_TRACE1 ;
196+ oauth2_log_sink_level_set (
197+ cfg -> sink , (sp && (sp -> log .level != -1 ))
198+ ? log_level_apache2oauth2 [sp -> log .level ]
199+ : OAUTH2_LOG_TRACE1 );
200200 }
201201
202202 apr_pool_cleanup_register (pool , s , parent_cleanup , child_cleanup );
@@ -254,14 +254,11 @@ oauth2_apache_request_context_init(request_rec *r,
254254 ctx -> r = r ;
255255
256256 // TODO: more elegant log-for-request handling
257- log_sink_apache = oauth2_mem_alloc (sizeof (oauth2_log_sink_t ));
258- log_sink_apache -> callback = request_log_cb ;
259- log_sink_apache -> level = (r && r -> log )
260- ? log_level_apache2oauth2 [r -> log -> level ]
261- : OAUTH2_LOG_TRACE1 ;
262- log_sink_apache -> level = OAUTH2_LOG_TRACE1 ;
263- log_sink_apache -> ctx = r ;
264- ctx -> log = oauth2_log_init (log_sink_apache -> level , log_sink_apache );
257+ oauth2_log_level_t level = (r && r -> log )
258+ ? log_level_apache2oauth2 [r -> log -> level ]
259+ : OAUTH2_LOG_TRACE1 ;
260+ log_sink_apache = oauth2_log_sink_create (level , request_log_cb , r );
261+ ctx -> log = oauth2_log_init (level , log_sink_apache );
265262
266263 ctx -> request = oauth2_http_request_init (ctx -> log );
267264
0 commit comments