X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/5a97de8c98502af9f74cfceb924fa02e0fd80925..507785035fffb029577ed608142f0cb8a43f77e9:/src/xbt/log.c diff --git a/src/xbt/log.c b/src/xbt/log.c index a121bd8776..075e482c0a 100644 --- a/src/xbt/log.c +++ b/src/xbt/log.c @@ -1,6 +1,6 @@ /* log - a generic logging facility in the spirit of log4j */ -/* Copyright (c) 2004-2014. The SimGrid Team. +/* Copyright (c) 2004-2015. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -11,20 +11,20 @@ #include /* snprintf */ #include /* snprintf */ -#include "portable.h" /* to get a working stdarg.h */ +#include "src/portable.h" -#include "xbt_modinter.h" +#include "src/xbt_modinter.h" #include "xbt/misc.h" #include "xbt/ex.h" #include "xbt/str.h" #include "xbt/sysdep.h" -#include "xbt/log_private.h" +#include "src/xbt/log_private.h" #include "xbt/dynar.h" #include "xbt/xbt_os_thread.h" int xbt_log_no_loc = 0; /* if set to true (with --log=no_loc), file localization will be omitted (for tesh tests) */ -static xbt_os_rmutex_t log_cat_init_mutex = NULL; +static xbt_os_mutex_t log_cat_init_mutex = NULL; /** \addtogroup XBT_log * @@ -552,7 +552,7 @@ void xbt_log_preinit(void) xbt_log_default_layout = xbt_log_layout_simple_new(NULL); _XBT_LOGV(XBT_LOG_ROOT_CAT).appender = xbt_log_default_appender; _XBT_LOGV(XBT_LOG_ROOT_CAT).layout = xbt_log_default_layout; - log_cat_init_mutex = xbt_os_rmutex_init(); + log_cat_init_mutex = xbt_os_mutex_init(); } static void xbt_log_connect_categories(void) @@ -562,19 +562,14 @@ static void xbt_log_connect_categories(void) /* xbt */ XBT_LOG_CONNECT(xbt); - XBT_LOG_CONNECT(graphxml_parse); XBT_LOG_CONNECT(log); XBT_LOG_CONNECT(module); - XBT_LOG_CONNECT(peer); XBT_LOG_CONNECT(replay); XBT_LOG_CONNECT(strbuff); XBT_LOG_CONNECT(xbt_cfg); XBT_LOG_CONNECT(xbt_dict); XBT_LOG_CONNECT(xbt_dict_cursor); XBT_LOG_CONNECT(xbt_dict_elm); -#ifdef XBT_USE_DEPRECATED - XBT_LOG_CONNECT(xbt_dict_multi); -#endif XBT_LOG_CONNECT(xbt_dyn); XBT_LOG_CONNECT(xbt_ex); XBT_LOG_CONNECT(xbt_fifo); @@ -584,8 +579,6 @@ static void xbt_log_connect_categories(void) XBT_LOG_CONNECT(xbt_mallocator); XBT_LOG_CONNECT(xbt_matrix); XBT_LOG_CONNECT(xbt_parmap); - XBT_LOG_CONNECT(xbt_queue); - XBT_LOG_CONNECT(xbt_set); XBT_LOG_CONNECT(xbt_sync); XBT_LOG_CONNECT(xbt_sync_os); @@ -594,19 +587,13 @@ static void xbt_log_connect_categories(void) /* bindings */ #ifdef HAVE_LUA - XBT_LOG_CONNECT(bindings); XBT_LOG_CONNECT(lua); - XBT_LOG_CONNECT(lua_comm); XBT_LOG_CONNECT(lua_host); XBT_LOG_CONNECT(lua_platf); - XBT_LOG_CONNECT(lua_process); - XBT_LOG_CONNECT(lua_state_cloner); - XBT_LOG_CONNECT(lua_task); - XBT_LOG_CONNECT(lua_utils); + XBT_LOG_CONNECT(lua_debug); #endif /* instr */ -#ifdef HAVE_TRACING XBT_LOG_CONNECT(instr); XBT_LOG_CONNECT(instr_api); XBT_LOG_CONNECT(instr_config); @@ -620,11 +607,9 @@ static void xbt_log_connect_categories(void) XBT_LOG_CONNECT(instr_paje_values); XBT_LOG_CONNECT(instr_resource); XBT_LOG_CONNECT(instr_routing); - XBT_LOG_CONNECT(instr_sd); XBT_LOG_CONNECT(instr_surf); XBT_LOG_CONNECT(instr_trace); XBT_LOG_CONNECT(instr_TI_trace); -#endif /* jedule */ #ifdef HAVE_JEDULE @@ -641,17 +626,26 @@ static void xbt_log_connect_categories(void) XBT_LOG_CONNECT(mc_compare); XBT_LOG_CONNECT(mc_diff); XBT_LOG_CONNECT(mc_dwarf); - XBT_LOG_CONNECT(mc_global); XBT_LOG_CONNECT(mc_hash); XBT_LOG_CONNECT(mc_ignore); XBT_LOG_CONNECT(mc_liveness); XBT_LOG_CONNECT(mc_memory); - XBT_LOG_CONNECT(mc_memory_map); XBT_LOG_CONNECT(mc_page_snapshot); XBT_LOG_CONNECT(mc_request); XBT_LOG_CONNECT(mc_safety); XBT_LOG_CONNECT(mc_visited); + XBT_LOG_CONNECT(mc_client); + XBT_LOG_CONNECT(mc_client_api); + XBT_LOG_CONNECT(mc_comm_pattern); + XBT_LOG_CONNECT(mc_process); + XBT_LOG_CONNECT(mc_protocol); + XBT_LOG_CONNECT(mc_RegionSnaphot); + XBT_LOG_CONNECT(mc_ModelChecker); + XBT_LOG_CONNECT(mc_state); #endif + XBT_LOG_CONNECT(mc_global); + XBT_LOG_CONNECT(mc_config); + XBT_LOG_CONNECT(mc_record); /* msg */ XBT_LOG_CONNECT(msg); @@ -664,7 +658,10 @@ static void xbt_log_connect_categories(void) XBT_LOG_CONNECT(msg_synchro); XBT_LOG_CONNECT(msg_task); XBT_LOG_CONNECT(msg_vm); - + + /* sg */ + XBT_LOG_CONNECT(sg_host); + /* simdag */ XBT_LOG_CONNECT(sd); XBT_LOG_CONNECT(sd_daxparse); @@ -673,7 +670,6 @@ static void xbt_log_connect_categories(void) #endif XBT_LOG_CONNECT(sd_kernel); XBT_LOG_CONNECT(sd_task); - XBT_LOG_CONNECT(sd_workstation); /* simix */ XBT_LOG_CONNECT(simix); @@ -694,8 +690,6 @@ static void xbt_log_connect_categories(void) /* surf */ XBT_LOG_CONNECT(surf); - XBT_LOG_CONNECT(platf_generator); - XBT_LOG_CONNECT(random); XBT_LOG_CONNECT(surf_config); XBT_LOG_CONNECT(surf_cpu); XBT_LOG_CONNECT(surf_cpu_cas); @@ -706,16 +700,8 @@ static void xbt_log_connect_categories(void) XBT_LOG_CONNECT(surf_lagrange_dichotomy); XBT_LOG_CONNECT(surf_maxmin); XBT_LOG_CONNECT(surf_network); -#ifdef HAVE_GTNETS - XBT_LOG_CONNECT(surf_network_gtnets); - XBT_LOG_CONNECT(surf_network_gtnets_interface); - XBT_LOG_CONNECT(surf_network_gtnets_simulator); - XBT_LOG_CONNECT(surf_network_gtnets_topology); -#endif #ifdef HAVE_NS3 - XBT_LOG_CONNECT(surf_network_ns3); - XBT_LOG_CONNECT(interface_ns3); - XBT_LOG_CONNECT(simulator_ns3); + XBT_LOG_CONNECT(ns3); #endif XBT_LOG_CONNECT(surf_parse); XBT_LOG_CONNECT(surf_route); @@ -730,8 +716,8 @@ static void xbt_log_connect_categories(void) XBT_LOG_CONNECT(surf_route_vivaldi); XBT_LOG_CONNECT(surf_storage); XBT_LOG_CONNECT(surf_trace); - XBT_LOG_CONNECT(surf_vm_workstation); - XBT_LOG_CONNECT(surf_workstation); + XBT_LOG_CONNECT(surf_vm); + XBT_LOG_CONNECT(surf_host); #endif /* simgrid_EXPORTS */ } @@ -804,7 +790,7 @@ static void log_cat_exit(xbt_log_category_t cat) void xbt_log_postexit(void) { XBT_VERB("Exiting log"); - xbt_os_rmutex_destroy(log_cat_init_mutex); + xbt_os_mutex_destroy(log_cat_init_mutex); xbt_dynar_free(&xbt_log_settings); log_cat_exit(&_XBT_LOGV(XBT_LOG_ROOT_CAT)); } @@ -899,8 +885,7 @@ static void _xbt_log_cat_apply_set(xbt_log_category_t category, if (setting->fmt) { xbt_log_layout_set(category, xbt_log_layout_format_new(setting->fmt)); - XBT_DEBUG("Apply settings for category '%s': set format to %s", - category->name, setting->fmt); + XBT_DEBUG("Apply settings for category '%s': set format to %s", category->name, setting->fmt); } if (setting->additivity != -1) { @@ -930,14 +915,12 @@ int _xbt_log_cat_init(xbt_log_category_t category, { #define _xbt_log_cat_init(a, b) (0) - if (log_cat_init_mutex != NULL) { - xbt_os_rmutex_acquire(log_cat_init_mutex); - } + if (log_cat_init_mutex != NULL) + xbt_os_mutex_acquire(log_cat_init_mutex); if (category->initialized) { - if (log_cat_init_mutex != NULL) { - xbt_os_rmutex_release(log_cat_init_mutex); - } + if (log_cat_init_mutex != NULL) + xbt_os_mutex_release(log_cat_init_mutex); return priority >= category->threshold; } @@ -1014,9 +997,8 @@ int _xbt_log_cat_init(xbt_log_category_t category, } category->initialized = 1; - if (log_cat_init_mutex != NULL) { - xbt_os_rmutex_release(log_cat_init_mutex); - } + if (log_cat_init_mutex != NULL) + xbt_os_mutex_release(log_cat_init_mutex); return priority >= category->threshold; #undef _xbt_log_cat_init @@ -1104,7 +1086,6 @@ static xbt_log_setting_t _xbt_log_parse_setting(const char *control_string) dot = control_string; control_string += strcspn(control_string, ":= "); eq = control_string; - control_string += strcspn(control_string, " "); if(*dot != '.' && (*eq == '=' || *eq == ':')) xbt_die ("Invalid control string '%s'", orig_control_string); @@ -1129,9 +1110,12 @@ static xbt_log_setting_t _xbt_log_parse_setting(const char *control_string) } if(ithresh = (e_xbt_log_priority_t) i; } else { @@ -1166,9 +1150,9 @@ static xbt_log_setting_t _xbt_log_parse_setting(const char *control_string) if (!strncmp(neweq, "file:", 5)) { set->appender = xbt_log_appender_file_new(neweq + 5); }else if (!strncmp(neweq, "rollfile:", 9)) { - set->appender = xbt_log_appender2_file_new(neweq + 9,1); + set->appender = xbt_log_appender2_file_new(neweq + 9,1); }else if (!strncmp(neweq, "splitfile:", 10)) { - set->appender = xbt_log_appender2_file_new(neweq + 10,0); + set->appender = xbt_log_appender2_file_new(neweq + 10,0); } else { THROWF(arg_error, 0, "Unknown appender log type: '%s'", neweq); } @@ -1177,7 +1161,7 @@ static xbt_log_setting_t _xbt_log_parse_setting(const char *control_string) set->fmt = xbt_strdup(eq + 1); } else { char buff[512]; - snprintf(buff, min(512, eq - dot), "%s", dot + 1); + snprintf(buff, MIN(512, eq - dot), "%s", dot + 1); THROWF(arg_error, 0, "Unknown setting of the log category: '%s'", buff); }