X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/24b8008bb424160e633b1374f54dcd89bdcb9749..de6f834747f9af2af9f110ee3ba3bb9f3f0d01f3:/src/xbt/log.c diff --git a/src/xbt/log.c b/src/xbt/log.c index a5a73480db..e76d823efc 100644 --- a/src/xbt/log.c +++ b/src/xbt/log.c @@ -2,11 +2,10 @@ /* log - a generic logging facility in the spirit of log4j */ -/* Authors: Martin Quinson */ -/* Copyright (C) 2003, 2004 Martin Quinson. */ +/* Copyright (c) 2003, 2004 Martin Quinson. All rights reserved. */ /* 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. */ + * under the terms of the license (GNU LGPL) which comes with this package. */ #include #include @@ -50,11 +49,42 @@ s_xbt_log_category_t _XBT_LOGV(XBT_LOG_ROOT_CAT) = { NULL, 0 }; -XBT_LOG_NEW_SUBCATEGORY(gras,XBT_LOG_ROOT_CAT,"All GRAS categories"); -XBT_LOG_NEW_SUBCATEGORY(xbt,XBT_LOG_ROOT_CAT,"All XBT categories (gras toolbox)"); +XBT_LOG_NEW_SUBCATEGORY(xbt,XBT_LOG_ROOT_CAT,"All XBT categories (simgrid toolbox)"); XBT_LOG_NEW_SUBCATEGORY(surf,XBT_LOG_ROOT_CAT,"All SURF categories"); XBT_LOG_NEW_DEFAULT_SUBCATEGORY(log,xbt,"Loggings from the logging mecanism itself"); +void xbt_log_init(int *argc,char **argv, const char *defaultlog) { + int i,j; + char *opt; + int found=0; + + /** Set logs and init log submodule */ + for (i=1; i<*argc; i++) { + if (!strncmp(argv[i],"--gras-log=",strlen("--gras-log="))) { + found = 1; + opt=strchr(argv[i],'='); + opt++; + xbt_log_control_set(opt); + DEBUG1("Did apply '%s' as log setting",opt); + /*remove this from argv*/ + for (j=i+1; j<*argc; j++) { + argv[j-1] = argv[j]; + } + argv[j-1] = NULL; + (*argc)--; + i--; /* compensate effect of next loop incrementation */ + } + } + if (!found && defaultlog) { + xbt_log_control_set(defaultlog); + } +} + +void xbt_log_exit(void) { + VERB0("Exiting log"); + xbt_dynar_free(&xbt_log_settings); + VERB0("Exited log"); +} static void _apply_control(xbt_log_category_t cat) { int cursor; @@ -364,8 +394,3 @@ void xbt_log_appender_set(xbt_log_category_t cat, xbt_log_appender_t app) { cat->appender = app; } -void xbt_log_exit(void) { - VERB0("Exiting log"); - xbt_dynar_free(&xbt_log_settings); - VERB0("Exited log"); -}