2005-01-20 23:22:22 +00:00
|
|
|
// Berkeley Open Infrastructure for Network Computing
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2005 University of California
|
2004-07-13 13:54:09 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// This is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation;
|
|
|
|
// either version 2.1 of the License, or (at your option) any later version.
|
2004-07-13 13:54:09 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// This software is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
2002-04-30 22:22:54 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// To view the GNU Lesser General Public License visit
|
|
|
|
// http://www.gnu.org/copyleft/lesser.html
|
|
|
|
// or write to the Free Software Foundation, Inc.,
|
|
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2003-10-16 19:03:49 +00:00
|
|
|
#include "cpp.h"
|
2004-03-04 11:41:43 +00:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
2004-06-16 23:16:08 +00:00
|
|
|
#include "boinc_win.h"
|
2004-03-04 11:41:43 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _WIN32
|
2004-07-13 13:54:09 +00:00
|
|
|
#include <cstdio>
|
|
|
|
#include <cstring>
|
2004-03-04 11:41:43 +00:00
|
|
|
#endif
|
2002-04-30 22:22:54 +00:00
|
|
|
|
|
|
|
#include "error_numbers.h"
|
2002-08-12 23:18:47 +00:00
|
|
|
#include "file_names.h"
|
2004-04-08 08:15:23 +00:00
|
|
|
#include "client_msgs.h"
|
2002-04-30 22:22:54 +00:00
|
|
|
#include "parse.h"
|
|
|
|
|
|
|
|
#include "log_flags.h"
|
2004-03-01 19:11:12 +00:00
|
|
|
#include "filesys.h"
|
2002-04-30 22:22:54 +00:00
|
|
|
|
|
|
|
LOG_FLAGS log_flags;
|
|
|
|
|
|
|
|
LOG_FLAGS::LOG_FLAGS() {
|
2003-03-13 21:49:52 +00:00
|
|
|
|
|
|
|
// informational output is on by default
|
|
|
|
//
|
|
|
|
task = true;
|
|
|
|
file_xfer = true;
|
|
|
|
sched_ops = true;
|
|
|
|
|
|
|
|
// debugging output is off by default
|
|
|
|
//
|
|
|
|
state_debug = false;
|
|
|
|
task_debug = false;
|
|
|
|
file_xfer_debug = false;
|
|
|
|
sched_op_debug = false;
|
|
|
|
http_debug = false;
|
2004-03-27 00:45:27 +00:00
|
|
|
proxy_debug = false;
|
2003-03-13 21:49:52 +00:00
|
|
|
time_debug = false;
|
|
|
|
net_xfer_debug = false;
|
2002-08-30 21:32:31 +00:00
|
|
|
measurement_debug = false;
|
2004-06-11 20:52:27 +00:00
|
|
|
guirpc_debug = false;
|
2005-05-10 03:42:01 +00:00
|
|
|
sched_cpu_debug = false;
|
2004-03-25 03:48:54 +00:00
|
|
|
dont_check_file_sizes = false;
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
|
|
|
|
2002-07-15 23:21:20 +00:00
|
|
|
// Parse log flag preferences
|
|
|
|
//
|
2002-04-30 22:22:54 +00:00
|
|
|
int LOG_FLAGS::parse(FILE* in) {
|
|
|
|
char buf[256];
|
2002-08-15 22:03:41 +00:00
|
|
|
|
2002-04-30 22:22:54 +00:00
|
|
|
fgets(buf, 256, in);
|
|
|
|
if (!match_tag(buf, "<log_flags>")) return ERR_XML_PARSE;
|
|
|
|
while (fgets(buf, 256, in)) {
|
|
|
|
if (match_tag(buf, "</log_flags>")) return 0;
|
|
|
|
else if (match_tag(buf, "<task/>")) {
|
|
|
|
task = true;
|
|
|
|
continue;
|
2003-03-13 21:49:52 +00:00
|
|
|
} else if (match_tag(buf, "<file_xfer/>")) {
|
2002-04-30 22:22:54 +00:00
|
|
|
file_xfer = true;
|
|
|
|
continue;
|
2003-03-13 21:49:52 +00:00
|
|
|
} else if (match_tag(buf, "<sched_ops/>")) {
|
2002-04-30 22:22:54 +00:00
|
|
|
sched_ops = true;
|
|
|
|
continue;
|
2003-03-13 21:49:52 +00:00
|
|
|
} else if (match_tag(buf, "<state_debug/>")) {
|
2002-04-30 22:22:54 +00:00
|
|
|
state_debug = true;
|
|
|
|
continue;
|
2003-03-13 21:49:52 +00:00
|
|
|
} else if (match_tag(buf, "<task_debug/>")) {
|
2002-04-30 22:22:54 +00:00
|
|
|
task_debug = true;
|
|
|
|
continue;
|
2003-03-13 21:49:52 +00:00
|
|
|
} else if (match_tag(buf, "<file_xfer_debug/>")) {
|
2002-04-30 22:22:54 +00:00
|
|
|
file_xfer_debug = true;
|
|
|
|
continue;
|
2003-03-13 21:49:52 +00:00
|
|
|
} else if (match_tag(buf, "<sched_op_debug/>")) {
|
2002-04-30 22:22:54 +00:00
|
|
|
sched_op_debug = true;
|
|
|
|
continue;
|
2003-03-13 21:49:52 +00:00
|
|
|
} else if (match_tag(buf, "<http_debug/>")) {
|
2002-04-30 22:22:54 +00:00
|
|
|
http_debug = true;
|
|
|
|
continue;
|
2004-03-27 00:45:27 +00:00
|
|
|
} else if (match_tag(buf, "<proxy_debug/>")) {
|
|
|
|
proxy_debug = true;
|
|
|
|
continue;
|
2003-03-13 21:49:52 +00:00
|
|
|
} else if (match_tag(buf, "<time_debug/>")) {
|
2002-04-30 22:22:54 +00:00
|
|
|
time_debug = true;
|
|
|
|
continue;
|
2003-03-13 21:49:52 +00:00
|
|
|
} else if (match_tag(buf, "<net_xfer_debug/>")) {
|
2002-04-30 22:22:54 +00:00
|
|
|
net_xfer_debug = true;
|
|
|
|
continue;
|
2003-03-13 21:49:52 +00:00
|
|
|
} else if (match_tag(buf, "<measurement_debug/>")) {
|
2002-08-30 21:32:31 +00:00
|
|
|
measurement_debug = true;
|
|
|
|
continue;
|
2003-03-13 21:49:52 +00:00
|
|
|
} else if (match_tag(buf, "<poll_debug/>")) {
|
2002-08-28 21:50:51 +00:00
|
|
|
poll_debug = true;
|
|
|
|
continue;
|
2004-06-11 20:52:27 +00:00
|
|
|
} else if (match_tag(buf, "<guirpc_debug/>")) {
|
|
|
|
guirpc_debug = true;
|
|
|
|
continue;
|
2005-05-10 03:42:01 +00:00
|
|
|
} else if (match_tag(buf, "<sched_cpu_debug/>")) {
|
|
|
|
sched_cpu_debug = true;
|
|
|
|
continue;
|
2004-03-25 01:25:52 +00:00
|
|
|
} else if (match_tag(buf, "<dont_check_file_sizes/>")) {
|
|
|
|
dont_check_file_sizes = true;
|
|
|
|
continue;
|
2002-08-28 21:50:51 +00:00
|
|
|
}
|
2003-07-03 05:01:29 +00:00
|
|
|
else msg_printf(NULL, MSG_ERROR, "LOG_FLAGS::parse: unrecognized: %s\n", buf);
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
|
|
|
return ERR_XML_PARSE;
|
|
|
|
}
|
2002-08-12 23:18:47 +00:00
|
|
|
|
|
|
|
void read_log_flags() {
|
|
|
|
FILE* f;
|
|
|
|
|
2004-03-01 19:11:12 +00:00
|
|
|
if (boinc_file_exists(LOG_FLAGS_FILE)) {
|
2005-03-10 22:05:42 +00:00
|
|
|
f = boinc_fopen(LOG_FLAGS_FILE, "r");
|
2002-08-12 23:18:47 +00:00
|
|
|
log_flags.parse(f);
|
|
|
|
fclose(f);
|
|
|
|
}
|
2004-03-01 19:11:12 +00:00
|
|
|
|
2002-08-12 23:18:47 +00:00
|
|
|
}
|
2004-12-08 00:40:19 +00:00
|
|
|
|
2005-01-02 18:29:53 +00:00
|
|
|
const char *BOINC_RCSID_5f23de6652 = "$Id$";
|