2005-01-20 23:22:22 +00:00
|
|
|
// Berkeley Open Infrastructure for Network Computing
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2005 University of California
|
2003-06-11 22:42:49 +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.
|
2003-06-11 22:42:49 +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.
|
2003-06-11 22:42:49 +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
|
2003-06-11 22:42:49 +00:00
|
|
|
|
2004-03-05 04:37:53 +00:00
|
|
|
#ifdef _WIN32
|
2004-06-16 23:16:08 +00:00
|
|
|
#include "boinc_win.h"
|
2005-11-21 18:34:44 +00:00
|
|
|
#else
|
|
|
|
#include "config.h"
|
2004-07-13 13:54:09 +00:00
|
|
|
#include <cstdarg>
|
2004-09-30 21:41:09 +00:00
|
|
|
#include <deque>
|
2004-04-08 08:15:23 +00:00
|
|
|
#endif
|
2004-03-05 04:37:53 +00:00
|
|
|
|
2004-09-30 21:41:09 +00:00
|
|
|
using std::deque;
|
|
|
|
|
2003-06-11 22:42:49 +00:00
|
|
|
#include "log_flags.h"
|
2005-01-28 19:01:08 +00:00
|
|
|
#include "client_types.h"
|
2004-04-08 08:15:23 +00:00
|
|
|
#include "client_msgs.h"
|
2003-06-11 22:42:49 +00:00
|
|
|
|
2004-06-17 04:49:34 +00:00
|
|
|
#define MAX_SAVED_MESSAGES 1000
|
|
|
|
|
2004-04-08 08:15:23 +00:00
|
|
|
CLIENT_MSG_LOG log_messages;
|
2003-06-11 22:42:49 +00:00
|
|
|
|
2004-04-08 08:15:23 +00:00
|
|
|
const char* CLIENT_MSG_LOG::v_format_kind(int kind) const {
|
2003-06-11 22:42:49 +00:00
|
|
|
switch(kind) {
|
|
|
|
case DEBUG_STATE: return "DEBUG_STATE ";
|
|
|
|
case DEBUG_TASK: return "DEBUG_TASK ";
|
|
|
|
case DEBUG_FILE_XFER: return "DEBUG_FILE_XFER ";
|
|
|
|
case DEBUG_SCHED_OP: return "DEBUG_SCHED_OP ";
|
|
|
|
case DEBUG_HTTP: return "DEBUG_HTTP ";
|
2004-03-27 00:45:27 +00:00
|
|
|
case DEBUG_PROXY: return "DEBUG_PROXY ";
|
2003-06-11 22:42:49 +00:00
|
|
|
case DEBUG_TIME: return "DEBUG_TIME ";
|
|
|
|
case DEBUG_NET_XFER: return "DEBUG_NET_XFER ";
|
|
|
|
case DEBUG_MEASUREMENT: return "DEBUG_MEASUREMENT";
|
|
|
|
case DEBUG_POLL: return "DEBUG_POLL ";
|
2004-06-11 20:52:27 +00:00
|
|
|
case DEBUG_GUIRPC: return "DEBUG_GUIRPC ";
|
2005-05-10 03:42:01 +00:00
|
|
|
case DEBUG_SCHED_CPU: return "DEBUG_SCHED_CPU ";
|
2005-05-11 06:57:58 +00:00
|
|
|
case DEBUG_SCRSAVE: return "DEBUG_SCRSAVE ";
|
2003-06-11 22:42:49 +00:00
|
|
|
default: return "*** internal error: invalid MessageKind ***";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-04-08 08:15:23 +00:00
|
|
|
bool CLIENT_MSG_LOG::v_message_wanted(int kind) const {
|
2003-06-11 22:42:49 +00:00
|
|
|
switch (kind) {
|
|
|
|
case DEBUG_STATE: return log_flags.state_debug;
|
|
|
|
case DEBUG_TASK: return log_flags.task_debug;
|
|
|
|
case DEBUG_FILE_XFER: return log_flags.file_xfer_debug;
|
|
|
|
case DEBUG_SCHED_OP: return log_flags.sched_op_debug;
|
|
|
|
case DEBUG_HTTP: return log_flags.http_debug;
|
2004-03-27 00:45:27 +00:00
|
|
|
case DEBUG_PROXY: return log_flags.proxy_debug;
|
2003-06-11 22:42:49 +00:00
|
|
|
case DEBUG_TIME: return log_flags.time_debug;
|
|
|
|
case DEBUG_NET_XFER: return log_flags.net_xfer_debug;
|
|
|
|
case DEBUG_MEASUREMENT: return log_flags.measurement_debug;
|
|
|
|
case DEBUG_POLL: return log_flags.poll_debug;
|
2004-06-11 20:52:27 +00:00
|
|
|
case DEBUG_GUIRPC: return log_flags.guirpc_debug;
|
2005-05-10 03:42:01 +00:00
|
|
|
case DEBUG_SCHED_CPU: return log_flags.sched_cpu_debug;
|
2005-05-11 06:57:58 +00:00
|
|
|
case DEBUG_SCRSAVE: return log_flags.scrsave_debug;
|
2003-06-11 22:42:49 +00:00
|
|
|
default: return false;
|
|
|
|
}
|
|
|
|
}
|
2004-04-08 08:15:23 +00:00
|
|
|
|
2004-09-30 21:41:09 +00:00
|
|
|
// a dequeue of up to MAX_SAVED_MESSAGES most recent messages,
|
|
|
|
// stored in newest-first order
|
|
|
|
//
|
|
|
|
deque<MESSAGE_DESC*> message_descs;
|
2004-04-08 08:15:23 +00:00
|
|
|
|
|
|
|
// Takes a printf style formatted string, inserts the proper values,
|
|
|
|
// and passes it to show_message
|
|
|
|
// TODO: add translation functionality
|
|
|
|
//
|
2005-02-16 23:17:43 +00:00
|
|
|
void msg_printf(PROJECT *p, int priority, const char *fmt, ...) {
|
2004-08-12 12:44:55 +00:00
|
|
|
char buf[8192]; // output can be much longer than format
|
2004-04-08 08:15:23 +00:00
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
if (fmt == NULL) return;
|
|
|
|
|
|
|
|
va_start(ap, fmt); // Parses string for variables
|
|
|
|
vsprintf(buf, fmt, ap); // And convert symbols To actual numbers
|
|
|
|
va_end(ap); // Results are stored in text
|
|
|
|
|
|
|
|
show_message(p, buf, priority);
|
|
|
|
}
|
2004-06-17 04:49:34 +00:00
|
|
|
|
|
|
|
// stash message in memory
|
|
|
|
//
|
|
|
|
void record_message(PROJECT* p, int priority, int now, char* message) {
|
|
|
|
MESSAGE_DESC* mdp = new MESSAGE_DESC;
|
|
|
|
static int seqno = 1;
|
2005-01-28 19:01:08 +00:00
|
|
|
strcpy(mdp->project_name, "");
|
|
|
|
if (p) {
|
|
|
|
strcpy(mdp->project_name, p->get_project_name());
|
|
|
|
}
|
2004-06-17 04:49:34 +00:00
|
|
|
mdp->priority = priority;
|
|
|
|
mdp->timestamp = now;
|
|
|
|
mdp->seqno = seqno++;
|
|
|
|
mdp->message = message;
|
|
|
|
while (message_descs.size() > MAX_SAVED_MESSAGES) {
|
|
|
|
delete message_descs.back();
|
|
|
|
message_descs.pop_back();
|
|
|
|
}
|
|
|
|
message_descs.push_front(mdp);
|
2004-06-17 05:08:31 +00:00
|
|
|
}
|
2004-12-08 00:40:19 +00:00
|
|
|
|
2005-01-02 18:29:53 +00:00
|
|
|
const char *BOINC_RCSID_9572274f4f = "$Id$";
|