#include "xbt/dynar.h"
XBT_PUBLIC_DATA(int) (*xbt_pid) ();
-int xbt_log_no_loc = 0; /* if set to true (with --log=no_loc), file localization will be omitted (for tesh tests) */
+int xbt_log_no_loc = 0; /* if set to true (with --log=no_loc), file localization will be omitted (for tesh tests) */
/** \addtogroup XBT_log
*
If you want to mimic the simple layout with the format one, you would use this
-format: '[%%h:%%i:(%%I) %%r] %%l: [%%c/%%p] %%m%%n'. This is not completely correct
+format: '[%%h:%%i:(%%i) %%r] %%l: [%%c/%%p] %%m%%n'. This is not completely correct
because the simple layout do not display the message location for messages at
-priority INFO (thus, the fmt is '[%%h:%%i:(%%I) %%r] %%l: [%%c/%%p] %%m%%n' in this
+priority INFO (thus, the fmt is '[%%h:%%i:(%%i) %%r] [%%c/%%p] %%m%%n' in this
case). Moreover, if there is no process name (ie, messages coming from the
library itself, or test programs doing strange things) do not display the
process identity (thus, fmt is '[%%r] %%l: [%%c/%%p] %%m%%n' in that case, and '[%%r]
[%%c/%%p] %%m%%n' if they are at priority INFO).
-For now, there is only one format modifier: the precision field. You
-can for example specify %.4r to get the application age with 4
-numbers after the radix. Another limitation is that you cannot set
-specific layouts to the several priorities.
+For now, there is only two format modifiers: the precision and the
+width fields. You can for example specify %.4r to get the application
+age with 4 numbers after the radix, or %15p to get the process name
+on 15 columns. Finally, you can specify %10.6r to get the time on at
+most 10 columns, with 6 numbers after the radix.
+
+Note that when specifying the width, it is filled with spaces. That
+is to say that for example %5r in your format is converted to "% 5f"
+for printf (note the extra space); there is no way to fill the empty
+columns with 0 (ie, pass "%05f" to printf). Another limitation is
+that you cannot set specific layouts to the several priorities.
\subsection log_use_conf_app 3.1.4 Category appender
welcome here, too.
- *//*' */
+ *//*' */
xbt_log_appender_t xbt_log_default_appender = NULL; /* set in log_init */
s_xbt_log_category_t _XBT_LOGV(XBT_LOG_ROOT_CAT) = {
NULL /*parent */ , NULL /* firstChild */ , NULL /* nextSibling */ ,
- "root", xbt_log_priority_uninitialized /* threshold */ ,
- 0 /* isThreshInherited */ ,
- NULL /* appender */ , NULL /* layout */ ,
- 0 /* additivity */
+ "root", xbt_log_priority_uninitialized /* threshold */ ,
+ 0 /* isThreshInherited */ ,
+ NULL /* appender */ , NULL /* layout */ ,
+ 0 /* additivity */
};
XBT_LOG_NEW_CATEGORY(xbt, "All XBT categories (simgrid toolbox)");
/* create the default appender and install it in the root category,
which were already created (damnit. Too slow little beetle) */
-void xbt_log_preinit(void) {
+void xbt_log_preinit(void)
+{
xbt_log_default_appender = xbt_log_appender_file_new(NULL);
xbt_log_default_layout = xbt_log_layout_simple_new(NULL);
_XBT_LOGV(XBT_LOG_ROOT_CAT).appender = xbt_log_default_appender;
*
* xbt_log_control_set() is called on each string we got from cmd line
*/
-void xbt_log_init(int *argc, char **argv) {
+void xbt_log_init(int *argc, char **argv)
+{
int i, j;
char *opt;
if (strncmp(argv[i], "--log=", strlen("--log=")))
WARN2
- ("Option %.*s is deprecated and will disapear in the future. Use --log instead.",
- (int) (strchr(argv[i], '=') - argv[i]), argv[i]);
+ ("Option %.*s is deprecated and will disapear in the future. Use --log instead.",
+ (int) (strchr(argv[i], '=') - argv[i]), argv[i]);
opt = strchr(argv[i], '=');
opt++;
DEBUG2("Set %p as appender of category '%s'",
setting->appender, category->name);
}
-
#undef _xbt_log_cat_init
}
DEBUG3("Set %s (%s) as father of %s ",
category->parent->name,
(category->parent->threshold == xbt_log_priority_uninitialized ?
- "uninited" : xbt_log_priority_names[category->parent->threshold]),
+ "uninited" : xbt_log_priority_names[category->
+ parent->threshold]),
category->name);
xbt_log_parent_set(category, category->parent);
if (parent->threshold == xbt_log_priority_uninitialized) {
- _xbt_log_cat_init(parent, xbt_log_priority_uninitialized /* ignored */ );
+ _xbt_log_cat_init(parent,
+ xbt_log_priority_uninitialized /* ignored */ );
}
cat->threshold = parent->threshold;
*p -= 'a' - 'A';
}
}
- if (!strcmp(neweq, "ON") || !strcmp(neweq, "YES") || !strcmp(neweq, "1")) {
+ if (!strcmp(neweq, "ON") || !strcmp(neweq, "YES")
+ || !strcmp(neweq, "1")) {
set->additivity = 1;
} else {
set->additivity = 0;
} else {
char buff[512];
snprintf(buff, min(512, eq - dot), "%s", dot + 1);
- THROW1(arg_error, 0, "Unknown setting of the log category: '%s'", buff);
+ THROW1(arg_error, 0, "Unknown setting of the log category: '%s'",
+ buff);
}
set->catname = (char *) xbt_malloc(dot - name + 1);
DEBUG1("Parse log settings '%s'", control_string);
/* Special handling of no_loc request, which asks for any file localization to be omitted (for tesh runs) */
- if (!strcmp(control_string,"no_loc")) {
- xbt_log_no_loc=1;
+ if (!strcmp(control_string, "no_loc")) {
+ xbt_log_no_loc = 1;
return;
}
/* some initialization if this is the first time that this get called */
xbt_log_category_t cat = NULL;
set = _xbt_log_parse_setting(str);
- cat = _xbt_log_cat_searchsub(&_XBT_LOGV(XBT_LOG_ROOT_CAT), set->catname);
+ cat =
+ _xbt_log_cat_searchsub(&_XBT_LOGV(XBT_LOG_ROOT_CAT), set->catname);
if (cat) {
DEBUG0("Apply directly");
void xbt_log_layout_set(xbt_log_category_t cat, xbt_log_layout_t lay)
{
if (!cat->appender) {
- VERB1("No appender to category %s. Setting the file appender as default",
- cat->name);
+ VERB1
+ ("No appender to category %s. Setting the file appender as default",
+ cat->name);
xbt_log_appender_set(cat, xbt_log_appender_file_new(NULL));
}
- if (cat->layout && cat != &_XBT_LOGV(root)) {
- /* better leak the default layout than check every categories to
- change it */
+ if (cat->layout) {
if (cat->layout->free_) {
cat->layout->free_(cat->layout);
- free(cat->layout);
}
+ free(cat->layout);
}
cat->layout = lay;
xbt_log_additivity_set(cat, 0);