X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/3a3424cb8da52bf9abd5d2a97f43c6e477335eda..8412602500cae5f46897c6a85de6816c2ba8d427:/include/xbt/log.h diff --git a/include/xbt/log.h b/include/xbt/log.h index a0dc5cd0c8..7df75c3aeb 100644 --- a/include/xbt/log.h +++ b/include/xbt/log.h @@ -99,9 +99,15 @@ typedef enum { * XBT_LOG_NEW_CATEGORY */ #define XBT_LOG_NEW_SUBCATEGORY_helper(catName, parent, desc) \ XBT_EXPORT_NO_IMPORT(s_xbt_log_category_t) _XBT_LOGV(catName) = { \ - &_XBT_LOGV(parent), 0, 0, \ - #catName, xbt_log_priority_uninitialized, 1, \ - 0, 0, 1 \ + &_XBT_LOGV(parent), \ + NULL /* firstChild */, \ + NULL /* nextSibling */, \ + #catName, \ + xbt_log_priority_uninitialized /* threshold */, \ + 1 /* isThreshInherited */, \ + NULL /* appender */, \ + NULL /* layout */, \ + 1 /* additivity */ \ } /** * \ingroup XBT_log @@ -113,7 +119,7 @@ typedef enum { * Defines a new subcategory of the parent. */ #define XBT_LOG_NEW_SUBCATEGORY(catName, parent, desc) \ - extern s_xbt_log_category_t _XBT_LOGV(parent); \ + XBT_PUBLIC_DATA(s_xbt_log_category_t) _XBT_LOGV(parent); \ XBT_LOG_NEW_SUBCATEGORY_helper(catName, parent, desc) \ /** @@ -124,17 +130,9 @@ typedef enum { * * Creates a new subcategory of the root category. */ - -#if (defined(_WIN32) && !defined(DLL_STATIC)) # define XBT_LOG_NEW_CATEGORY(catName,desc) \ - XBT_EXPORT_NO_IMPORT(s_xbt_log_category_t) _XBT_LOGV(catName) = { \ - 0, 0, 0, \ - #catName, xbt_log_priority_uninitialized, 1, \ - 0, 1 \ - } -#else -# define XBT_LOG_NEW_CATEGORY(catName,desc) XBT_LOG_NEW_SUBCATEGORY_helper(catName, XBT_LOG_ROOT_CAT, desc) -#endif + XBT_LOG_NEW_SUBCATEGORY_helper(catName, XBT_LOG_ROOT_CAT, desc) + /** * \ingroup XBT_log @@ -160,24 +158,27 @@ typedef enum { * Creates a new subcategory of the root category and makes it the default * (used by macros that don't explicitly specify a category). */ +/* Damnit Malek. There is no difference between the WINDOWS version and the regular one. + * Moreover, portability cruft MUST be kept out of this file. If you need another definition of EXPORT_NO_IMPORT, do so in misc, not here. + * Killing your crufty definition once again (I hate dupplicated code). Please do not readd them without a good justification #if (defined(_WIN32) && !defined(DLL_STATIC)) # define XBT_LOG_NEW_ROOT_SUBCATEGORY(cname,desc) \ XBT_EXPORT_NO_IMPORT(s_xbt_log_category_t) _XBT_LOGV(cname) = { \ 0, 0, 0, \ #cname, xbt_log_priority_uninitialized, 1, \ - 0, 1 \ + 0, 0, 1 \ } - # define XBT_LOG_NEW_DEFAULT_CATEGORY(cname,desc) \ XBT_LOG_NEW_ROOT_SUBCATEGORY(cname,desc); \ XBT_LOG_DEFAULT_CATEGORY(cname) #else + */ # define XBT_LOG_NEW_DEFAULT_CATEGORY(cname,desc) \ XBT_LOG_NEW_CATEGORY(cname,desc); \ - XBT_LOG_DEFAULT_CATEGORY(cname) -#endif + XBT_LOG_DEFAULT_CATEGORY(cname) +//#endif @@ -232,6 +233,7 @@ typedef struct xbt_log_category_s s_xbt_log_category_t,*xbt_log_category_t; /* * Do NOT access any members of this structure directly. FIXME: move to private? */ +#define XBT_LOG_BUFF_SIZE 2048 /* Size of the static string in which we build the log string */ struct xbt_log_category_s { xbt_log_category_t parent; xbt_log_category_t firstChild; @@ -244,27 +246,15 @@ struct xbt_log_category_s { int additivity; }; -struct xbt_log_appender_s { - void (*do_append) (xbt_log_appender_t this_appender, - char *event); - void (*free_) (xbt_log_appender_t this_); - void *data; -}; - -struct xbt_log_layout_s { - char *(*do_layout)(xbt_log_layout_t l, - xbt_log_event_t event, const char *fmt); - void (*free_) (xbt_log_layout_t l); - void *data; -} ; - struct xbt_log_event_s { xbt_log_category_t cat; e_xbt_log_priority_t priority; const char* fileName; const char* functionName; - int lineNum; + int lineNum; va_list ap; + va_list ap_copy; /* need a copy to launch dynamic layouts when the static ones overflowed */ + char buffer[XBT_LOG_BUFF_SIZE]; }; /** @@ -343,9 +333,8 @@ XBT_PUBLIC(int) _xbt_log_cat_init(xbt_log_category_t category, e_xbt_log_priority_t priority); -extern XBT_IMPORT_NO_EXPORT(s_xbt_log_category_t) _XBT_LOGV(XBT_LOG_ROOT_CAT); +XBT_PUBLIC_DATA(s_xbt_log_category_t) _XBT_LOGV(XBT_LOG_ROOT_CAT); -XBT_LOG_EXTERNAL_CATEGORY(GRAS); extern xbt_log_appender_t xbt_log_default_appender; extern xbt_log_layout_t xbt_log_default_layout; @@ -357,7 +346,7 @@ extern xbt_log_layout_t xbt_log_default_layout; /** * \ingroup XBT_log * \param catName name of the category - * \param priority minimal priority to be enabled to return true + * \param priority minimal priority to be enabled to return true (must be #e_xbt_log_priority_t) * \hideinitializer * * Returns true if the given priority is enabled for the category. @@ -397,7 +386,7 @@ extern xbt_log_layout_t xbt_log_default_layout; #define _XBT_LOG_PRE(catv, priority) do { \ if (_XBT_LOG_ISENABLEDV(catv, priority)) { \ s_xbt_log_event_t _log_ev = \ - {NULL,priority,__FILE__,_XBT_FUNCTION,__LINE__}; \ + {NULL,priority,__FILE__,_XBT_FUNCTION,__LINE__}; \ _log_ev.cat = &(catv); \ _xbt_log_event_log(&_log_ev \