@@ -3,8 +3,8 @@ static const char version[] = "$Id$";
3
3
/*
4
4
* category.c
5
5
*
6
- * Copyright 2001-2002, Cimai Technology SA (www.cimai .com). All rights reserved.
7
- * Copyright 2001-2002, Cedric Le Goater <legoater@cimai .com>. All rights reserved.
6
+ * Copyright 2001-2002, Meiosys SA (www.meiosys .com). All rights reserved.
7
+ * Copyright 2001-2002, Cedric Le Goater <legoater@meiosys .com>. All rights reserved.
8
8
*
9
9
* See the COPYING file for the terms of usage and distribution.
10
10
*/
@@ -191,19 +191,6 @@ extern void log4c_category_print(const log4c_category_t* this, FILE* a_stream)
191
191
}
192
192
193
193
/*******************************************************************************/
194
- static void call_appenders (const log4c_category_t * this ,
195
- log4c_logging_event_t * a_event )
196
- {
197
- if (!this )
198
- return ;
199
-
200
- if (this -> cat_appender )
201
- log4c_appender_append (this -> cat_appender , a_event );
202
-
203
- if (this -> cat_additive && this -> cat_parent )
204
- call_appenders (this -> cat_parent , a_event );
205
- }
206
-
207
194
extern void __log4c_category_vlog (const log4c_category_t * this ,
208
195
const log4c_location_info_t * a_locinfo ,
209
196
int a_priority ,
@@ -212,21 +199,31 @@ extern void __log4c_category_vlog(const log4c_category_t* this,
212
199
{
213
200
char * message ;
214
201
log4c_logging_event_t evt ;
202
+ const log4c_category_t * cat ;
203
+ int yes = 0 ;
215
204
216
205
if (!this )
217
206
return ;
207
+
208
+ /* check if an appender is defined in the category hierarchy */
209
+ for (cat = this ; cat ; cat = cat -> cat_parent ) {
210
+ if (cat -> cat_appender )
211
+ yes ++ ;
212
+ }
213
+
214
+ if (!yes )
215
+ return ;
218
216
219
217
if (!log4c_rc -> config .bufsize )
220
218
message = sd_vsprintf (a_format , a_args );
221
219
else {
222
220
int n ;
223
-
221
+
224
222
message = alloca (log4c_rc -> config .bufsize );
225
223
if ( (n = vsnprintf (message , log4c_rc -> config .bufsize , a_format , a_args ))
226
224
>= log4c_rc -> config .bufsize )
227
225
sd_error ("truncating message of %d bytes (bufsize = %d)" , n ,
228
- log4c_rc -> config .bufsize );
229
-
226
+ log4c_rc -> config .bufsize );
230
227
}
231
228
232
229
evt .evt_category = this -> cat_name ;
@@ -235,8 +232,13 @@ extern void __log4c_category_vlog(const log4c_category_t* this,
235
232
evt .evt_loc = a_locinfo ;
236
233
gettimeofday (& evt .evt_timestamp , NULL );
237
234
238
- call_appenders (this , & evt );
239
-
235
+ for (cat = this ; cat ; cat = cat -> cat_parent ) {
236
+ if (cat -> cat_appender )
237
+ log4c_appender_append (cat -> cat_appender , & evt );
238
+
239
+ if (!cat -> cat_additive ) break ;
240
+ }
241
+
240
242
if (!log4c_rc -> config .bufsize )
241
243
free (message );
242
244
}
0 commit comments