X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/092910cd23c789eb83b53efb69e85ae58ed3b1d0..91225594356c775dd384e44f5b5008cb3d9b7219:/src/xbt/log.c?ds=sidebyside diff --git a/src/xbt/log.c b/src/xbt/log.c index a9c834aa94..8e290e9f64 100644 --- a/src/xbt/log.c +++ b/src/xbt/log.c @@ -8,6 +8,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the license (GNU LGPL) which comes with this package. */ + +#include "Core/core_interface.h" #include "gras_private.h" #include #include @@ -27,7 +29,7 @@ static void _free_setting(void *s) { gras_log_setting_t *set=(gras_log_setting_t*)s; if (set) { free(set->catname); - free(set); +// free(set); FIXME: uncommenting this leads to segfault when more than one chunk is passed as gras-log } } @@ -47,7 +49,8 @@ gras_log_category_t _GRAS_LOGV(GRAS_LOG_ROOT_CAT) = { NULL, 0 }; GRAS_LOG_NEW_SUBCATEGORY(GRAS,GRAS_LOG_ROOT_CAT); -GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(log,GRAS); +GRAS_LOG_NEW_SUBCATEGORY(tbx,GRAS); +GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(log,tbx); static void _apply_control(gras_log_category_t* cat) { @@ -73,30 +76,32 @@ static void _apply_control(gras_log_category_t* cat) { if (cat->threshold <= gras_log_priority_verbose) { gras_log_event_t _log_ev = - {cat,gras_log_priority_verbose,__FILE__,__FUNCTION__,__LINE__, - "Apply settings for category '%s': set threshold to %s (=%d)",}; - _gras_log_event_log(&_log_ev, cat->name, - gras_log_priority_names[cat->threshold], cat->threshold); + {cat,gras_log_priority_verbose,__FILE__,__FUNCTION__,__LINE__}; + _gras_log_event_log(&_log_ev, + "Apply settings for category '%s': set threshold to %s (=%d)", + cat->name, + gras_log_priority_names[cat->threshold], cat->threshold); } } } if (!found && cat->threshold <= gras_log_priority_verbose) { gras_log_event_t _log_ev = - {cat,gras_log_priority_verbose,__FILE__,__FUNCTION__,__LINE__, - "Category '%s': inherited threshold = %s (=%d)",}; - _gras_log_event_log(&_log_ev, cat->name, + {cat,gras_log_priority_verbose,__FILE__,__FUNCTION__,__LINE__}; + _gras_log_event_log(&_log_ev, + "Category '%s': inherited threshold = %s (=%d)", + cat->name, gras_log_priority_names[cat->threshold], cat->threshold); } } -void _gras_log_event_log( gras_log_event_t* ev, ...) { +void _gras_log_event_log( gras_log_event_t* ev, const char *fmt, ...) { gras_log_category_t* cat = ev->cat; - va_start(ev->ap, ev); + va_start(ev->ap, fmt); while(1) { gras_log_appender_t* appender = cat->appender; if (appender != NULL) { - appender->do_append(appender, ev); + appender->do_append(appender, ev, fmt); } if (!cat->willLogToParent) break; @@ -232,7 +237,8 @@ static gras_error_t _gras_log_parse_setting(const char* control_string, if (!(set->catname=malloc(dot - name+1))) RAISE_MALLOC; - strncat(set->catname,name,dot-name); + strncpy(set->catname,name,dot-name); + set->catname[dot-name]='\0'; /* Just in case */ DEBUG1("This is for cat '%s'", set->catname); return no_error; } @@ -315,7 +321,8 @@ gras_error_t gras_log_control_set(const char* control_string) { if (control_string == NULL) return no_error; if (gras_log_settings == NULL) - TRY(gras_dynar_new(&gras_log_settings,sizeof(gras_log_setting_t*),_free_setting)); + TRY(gras_dynar_new(&gras_log_settings,sizeof(gras_log_setting_t*), + _free_setting)); if (!(set = malloc(sizeof(gras_log_setting_t)))) RAISE_MALLOC; @@ -341,7 +348,8 @@ gras_error_t gras_log_control_set(const char* control_string) { free(cs); } - TRYCATCH(_gras_log_cat_searchsub(&_GRAS_LOGV(root),set->catname,&cat),mismatch_error); + TRYCATCH(_gras_log_cat_searchsub(&_GRAS_LOGV(root),set->catname,&cat), + mismatch_error); if (errcode == mismatch_error) { DEBUG0("Store for further application"); DEBUG1("push %p to the settings",set); @@ -366,7 +374,8 @@ void gras_log_appender_set(gras_log_category_t* cat, gras_log_appender_t* app) { cat->appender = app; } -void gras_log_finalize(void); -void gras_log_finalize(void) { +void gras_log_exit(void) { + VERB0("Exiting log"); gras_dynar_free(gras_log_settings); + VERB0("Exited log"); }