From 97d0028e77e5132c8b7e9109f93240a292820df6 Mon Sep 17 00:00:00 2001 From: mquinson Date: Tue, 18 Aug 2009 14:25:56 +0000 Subject: [PATCH] Get the simple log format omit any file location when --log=no_loc is passed git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6597 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- examples/msg/masterslave/masterslave_bypass.tesh | 4 ++-- examples/msg/masterslave/masterslave_failure.tesh | 4 ++-- src/xbt/log.c | 6 ++++++ src/xbt/xbt_log_layout_simple.c | 5 +++-- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/examples/msg/masterslave/masterslave_bypass.tesh b/examples/msg/masterslave/masterslave_bypass.tesh index f86a783ef3..6228bd1d28 100644 --- a/examples/msg/masterslave/masterslave_bypass.tesh +++ b/examples/msg/masterslave/masterslave_bypass.tesh @@ -2,8 +2,8 @@ p Testing the bypassing of the flexml parser -$ $SG_TEST_EXENV masterslave/masterslave_bypass -> [0.000000] surf/surfxml_parse.c:447: [surf_parse/WARNING] Bypassing the XML parser since surf_parse_open received a NULL pointer. If it is not what you want, go fix your code. +$ $SG_TEST_EXENV masterslave/masterslave_bypass --log=no_loc +> [0.000000] [surf_parse/WARNING] Bypassing the XML parser since surf_parse_open received a NULL pointer. If it is not what you want, go fix your code. > [host A:master:(1) 0.000000] [msg_test/INFO] Got 1 slave(s) : > [host A:master:(1) 0.000000] [msg_test/INFO] host B > [host A:master:(1) 0.000000] [msg_test/INFO] Got 20 task to process : diff --git a/examples/msg/masterslave/masterslave_failure.tesh b/examples/msg/masterslave/masterslave_failure.tesh index 65e6c78030..685fb65d03 100644 --- a/examples/msg/masterslave/masterslave_failure.tesh +++ b/examples/msg/masterslave/masterslave_failure.tesh @@ -2,8 +2,8 @@ p Testing a simple master/slave example application handling failures -$ masterslave/masterslave_failure$EXEEXT ${srcdir:=.}/small_platform_with_failures.xml ${srcdir:=.}/masterslave/deployment_masterslave.xml --cfg:path=${srcdir} -> [0.000000] simix/smx_process.c:100: [simix_process/WARNING] Cannot launch process 'slave' on failed host 'Fafard' +$ masterslave/masterslave_failure$EXEEXT --log=no_loc ${srcdir:=.}/small_platform_with_failures.xml ${srcdir:=.}/masterslave/deployment_masterslave.xml --cfg:path=${srcdir} +> [0.000000] [simix_process/WARNING] Cannot launch process 'slave' on failed host 'Fafard' > [Tremblay:master:(1) 0.000000] [msg_test/INFO] Got 5 slave(s) : > [Tremblay:master:(1) 0.000000] [msg_test/INFO] Jupiter > [Tremblay:master:(1) 0.000000] [msg_test/INFO] Fafard diff --git a/src/xbt/log.c b/src/xbt/log.c index f985905a03..b1f767cacf 100644 --- a/src/xbt/log.c +++ b/src/xbt/log.c @@ -25,6 +25,7 @@ #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) */ /** \addtogroup XBT_log * @@ -1050,6 +1051,11 @@ void xbt_log_control_set(const char *control_string) return; 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; + return; + } /* some initialization if this is the first time that this get called */ if (xbt_log_settings == NULL) xbt_log_settings = xbt_dynar_new(sizeof(xbt_log_setting_t), diff --git a/src/xbt/xbt_log_layout_simple.c b/src/xbt/xbt_log_layout_simple.c index c42e398682..06d796f28a 100644 --- a/src/xbt/xbt_log_layout_simple.c +++ b/src/xbt/xbt_log_layout_simple.c @@ -17,6 +17,7 @@ #include "portable.h" extern const char *xbt_log_priority_names[7]; +extern int xbt_log_no_loc; static double begin_of_time = -1; @@ -39,7 +40,7 @@ static void xbt_log_layout_simple_dynamic(xbt_log_layout_t l, p += snprintf(p, 256 - (p - loc_buff), "%f] ", gras_os_time() - begin_of_time); - if (ev->priority != xbt_log_priority_info) + if (ev->priority != xbt_log_priority_info && xbt_log_no_loc==0) p += snprintf(p, 256 - (p - loc_buff), "%s:%d: ", ev->fileName, ev->lineNum); @@ -100,7 +101,7 @@ static void xbt_log_layout_simple_doit(xbt_log_layout_t l, check_overflow; /* Display file position if not INFO */ - if (ev->priority != xbt_log_priority_info) + if (ev->priority != xbt_log_priority_info && !xbt_log_no_loc) p += snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer), "%s:%d: ", ev->fileName, ev->lineNum); -- 2.20.1