forked from BOINC/boinc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsched_msgs.cpp
76 lines (64 loc) · 1.95 KB
/
sched_msgs.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
//
// BOINC 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 3 of the License, or (at your option) any later version.
//
// BOINC 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.
//
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
#include <string.h>
#include "config.h"
#include "sched_msgs.h"
SCHED_MSG_LOG log_messages;
const char* SCHED_MSG_LOG::v_format_kind(int kind) const {
switch(kind) {
case MSG_CRITICAL: return "[CRITICAL]";
case MSG_NORMAL: return "";
case MSG_DEBUG: return "[debug]";
default: return "*** internal error: invalid MessageKind ***";
}
}
bool SCHED_MSG_LOG::v_message_wanted(int kind) const {
return ( kind <= debug_level );
}
void SCHED_MSG_LOG::set_indent_level(const int new_indent_level) {
if (new_indent_level < 0) indent_level = 0;
else if (new_indent_level > 39) indent_level = 39;
else indent_level = new_indent_level;
memset(spaces, ' ', sizeof(spaces));
spaces[indent_level] = 0;
}
#ifdef _USING_FCGI_
SCHED_MSG_LOG::~SCHED_MSG_LOG() {
close();
}
void SCHED_MSG_LOG::close() {
if (output) {
flush();
fclose(output);
output = NULL;
}
}
#ifndef _USING_FCGI_
void SCHED_MSG_LOG::redirect(FILE* f) {
#else
void SCHED_MSG_LOG::redirect(FCGI_FILE* f) {
#endif
close();
output = f;
}
void SCHED_MSG_LOG::flush() {
if (output) {
fflush(output->stdio_stream);
}
}
#endif
const char *BOINC_RCSID_b40ff9bb53 = "$Id$";