2 * This file includes definitions for OpenStranded output mapping
4 * Copyright (C) 2009 David Kolossa
6 * This file is part of OpenStranded.
8 * OpenStranded is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
13 * OpenStranded is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with OpenStranded. If not, see <http://www.gnu.org/licenses/>.
27 * This is the class for OpenStranded output to either cout or cerr and/or log
36 void (*printer
)(std::string
);
39 Printer(void (*printer
)(std::string
));
48 operator<<(std::string msg
);
51 operator<<(const char *msg
);
66 operator<<(short msg
);
72 operator<<(long long msg
);
81 operator<<(unsigned int msg
);
84 operator<<(unsigned short msg
);
87 operator<<(unsigned long msg
);
90 operator<<(unsigned long long msg
);
99 operator<<(float msg
);
102 operator<<(double msg
);
111 vprintf(const char *format
, va_list args
);
114 printf(const char *format
, ...);
119 * The console mode flags.
120 * These flags determine which messages are displayed on the
121 * console and which aren't.
123 static int consoleFlags
;
126 * The logging mode flags.
127 * These flags determine which messages are written to log files
130 static int loggingFlags
;
133 * These flags indicate whether a printer has not finished its
136 static int isWriting
;
139 * Print fatal error message to stderr.
143 fatalPrinter(std::string msg
);
146 * Print common error message to stderr.
150 errorPrinter(std::string msg
);
153 * Print warning message to stderr.
157 warningPrinter(std::string msg
);
160 * Print a common message to stdout.
161 * Note that these messages can't be shut off.
165 msgPrinter(std::string msg
);
168 * Print a debug message.
172 debugPrinter(std::string msg
);
178 static Printer fatal
;
181 * The error console stream.
183 static Printer error
;
186 * The warning stream.
188 static Printer warning
;
198 static Printer debug
;
203 static FILE *logFile
;
205 static const int NONE
= 0;
206 static const int FATAL
= 1;
207 static const int ERROR
= 2;
208 static const int WARNING
= 4;
209 static const int DEBUG
= 8;
210 static const int MSG
= 16; // only used internally
212 static const char endl
= '\n';
217 * Set the log file name and open the file.
218 * This needs to be called at least once to allow log file
220 * @param fileName The new log file name
223 setLogFile(std::string fileName
);
227 * Get console mode flags.
228 * These flags indicate which messages should be written to the
229 * console (cout, cerr).
230 * @return The current console mode flags.
236 * Set console mode flags.
237 * These flags indicate which messages should be written to the
238 * console (cout, cerr).
239 * @param newflags The new console mode flags.
242 setConsoleFlags(int newflags
);
245 * Get logging mode flags.
246 * These flags indicate which messages should be written to
248 * @return The current logging mode flags.
254 * Set logging mode flags.
255 * These flags indicate which messages should be written to
257 * @param newflags The new logging mode flags.
260 setLoggingFlags(int newflags
);