1 // Copyright (C)2004 Landmark Graphics Corporation
2 // Copyright (C)2005, 2006 Sun Microsystems, Inc.
3 // Copyright (C)2014 D. R. Commander
4 //
5 // This library is free software and may be redistributed and/or modified under
6 // the terms of the wxWindows Library License, Version 3.1 or (at your option)
7 // any later version.  The full license is in the LICENSE.txt file included
8 // with this distribution.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 // wxWindows Library License for more details.
14 
15 #ifndef __LOG_H__
16 #define __LOG_H__
17 
18 #include "Mutex.h"
19 #include <stdio.h>
20 
21 
22 namespace vglutil
23 {
24 	class Log
25 	{
26 		public:
27 
28 			static Log *getInstance(void);
29 			void logTo(FILE *logFile);
30 			void logTo(char *logFileName);
31 			void print(const char *format, ...);
32 			// This class assumes that if you yell, you want it now
33 			void PRINT(const char *format, ...);
34 			void println(const char *format, ...);
35 			void PRINTLN(const char *format, ...);
flush(void)36 			void flush(void) { fflush(logFile); }
getFile(void)37 			FILE *getFile(void) { return logFile; }
38 
39 		private:
40 
Log()41 			Log()
42 			{
43 				logFile = stderr;  newFile = false;
44 			}
45 
~Log()46 			~Log() {}
47 
48 			static Log *instance;
49 			static CriticalSection mutex;
50 			FILE *logFile;
51 			bool newFile;
52 	};
53 }
54 
55 
56 #define vglout  (*(vglutil::Log::getInstance()))
57 
58 #endif  // __LOG_H__
59