New grow and skid sounds from remaxim
[supertux.git] / src / log.hpp
1 //  $Id$
2 //
3 //  SuperTux Debug Helper Functions
4 //  Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
5 //
6 //  This program is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU General Public License
8 //  as published by the Free Software Foundation; either version 2
9 //  of the License, or (at your option) any later version.
10 //
11 //  This program is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //  GNU General Public License for more details.
15 //
16 //  You should have received a copy of the GNU General Public License
17 //  along with this program; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 //  02111-1307, USA.
20 #ifndef __SUPERTUX_MSG_H__
21 #define __SUPERTUX_MSG_H__
22
23 #include <iostream>
24 #include <stdio.h>
25
26 #include "console.hpp"
27
28 #ifdef DEBUG
29
30 namespace {
31
32 inline std::ostream& log_debug_f(const char* file, int line) {
33   Console::output << "[DEBUG] " << file << ":" << line << " ";
34   return Console::output;
35 }
36
37 inline std::ostream& log_info_f(const char* file, int line) {
38   Console::output << "[INFO] " << file << ":" << line << " ";
39   return Console::output;
40 }
41
42 inline std::ostream& log_warning_f(const char* file, int line) {
43   Console::output << "[WARNING] " << file << ":" << line << " ";
44   return Console::output;
45 }
46
47 inline std::ostream& log_fatal_f(const char* file, int line) {
48   Console::output << "[FATAL] " << file << ":" << line << " ";
49   return Console::output;
50 }
51
52 }
53
54 #define log_debug log_debug_f(__FILE__, __LINE__)
55 #define log_info log_info_f(__FILE__, __LINE__)
56 #define log_warning log_warning_f(__FILE__, __LINE__)
57 #define log_fatal log_fatal_f(__FILE__, __LINE__)
58
59 #else
60
61 namespace {
62
63 inline std::ostream& log_fatal_f() {
64   Console::output << "Fatal: ";
65   return Console::output;
66 }
67
68 }
69
70 #define log_debug if (0) std::cerr
71 #define log_info std::cout
72 #define log_warning std::cerr
73 #define log_fatal log_fatal_f()
74
75 #endif
76
77 class Vector;
78 std::ostream& operator<< (std::ostream& str, const Vector& vector);
79 class Rect;
80 std::ostream& operator<< (std::ostream& str, const Rect& rect);
81
82 #endif