00001 // /////////////////// *********************** \\\\\\\\\\\\\\\\\\\\ \\ 00002 // 00003 // This file is part of the Sector 5, 3D graphic game. 00004 // Copyright (C) 2000-2002 by PC John. All rights reserved. 00005 // 00006 // This game is free software; you can redistribute it and/or 00007 // modify it under the terms of the GNU Lesser General Public License 00008 // version 2.1 as published by the Free Software Foundation. See the 00009 // file LICENSE.LGPL at the root directory of the distribution for 00010 // more details. 00011 // 00012 // If you want to use Sector 5 code for applications not compatible 00013 // with the LGPL license, please contact PC John at pcjohn@email.cz. 00014 // 00015 // \\\\\\\\\\\\\\\\\\\ *********************** //////////////////// // 00016 00017 00018 #ifndef LOG_H_INCLUDED_ 00019 #define LOG_H_INCLUDED_ 00020 00021 class SoError; 00022 00023 00024 00025 class Logger 00026 { 00027 public: 00028 00029 static void write(const char *, ...); 00030 static void write(const SoError *error, void *data = NULL); 00031 00032 inline Logger& operator<<(const char *s) { write(s); return *this; } 00033 inline Logger& operator<<(const unsigned char *s) { return operator<<((const char*)s); } 00034 inline Logger& operator<<(const signed char *s) { return operator<<((const char *)s); } 00035 inline Logger& operator<<(char c) { write("%c", c); return *this; } 00036 inline Logger& operator<<(unsigned char c) { return operator<<((char)c); } 00037 inline Logger& operator<<(signed char c) { return operator<<((char)c); } 00038 inline Logger& operator<<(short i) { return operator<<((int)i); } 00039 inline Logger& operator<<(unsigned short u) { return operator<<((unsigned int)u); } 00040 inline Logger& operator<<(int i) { write("%i", i); return *this; } 00041 inline Logger& operator<<(unsigned int u) { write("%u", u); return *this; } 00042 // FIXME: not sure about long and unsigned long implementation, 2002-02-13 PCJohn 00043 inline Logger& operator<<(long i) { return operator<<((int)i); } 00044 inline Logger& operator<<(unsigned long u) { return operator<<((unsigned int)u); } 00045 // FIXME: not sure about portability of floats, 2002-02-13 PCJohn 00046 inline Logger& operator<<(float f) { write("%g.FLT_DIG", f); return *this; } 00047 inline Logger& operator<<(double d) { write("%g.DBL_DIG", d); return *this; } 00048 inline Logger& operator<<(long double l) { write("%g.LDBL_DIG", l); return *this; } 00049 inline Logger& operator<<(const void *p) { write("%p", p); return *this; } 00050 00051 static void init(); 00052 static void scheduleShowLogMsg() { showMsg = true; } 00053 00054 private: 00055 00056 static void done(); 00057 static void showLogMsg(const char *s); 00058 00059 static bool showMsg; 00060 00061 }; 00062 00063 extern Logger logger; 00064 00065 00066 #endif /* LOG_H_INCLUDED_ */