src/util/log.cpp

Go to the documentation of this file.
00001 //  SuperTux Debug Helper Functions
00002 //  Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
00003 //  Copyright (C) 2010 Florian Forster <supertux at octo.it>
00004 //
00005 //  This program is free software: you can redistribute it and/or modify
00006 //  it under the terms of the GNU General Public License as published by
00007 //  the Free Software Foundation, either version 3 of the License, or
00008 //  (at your option) any later version.
00009 //
00010 //  This program is distributed in the hope that it will be useful,
00011 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 //  GNU General Public License for more details.
00014 //
00015 //  You should have received a copy of the GNU General Public License
00016 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017 
00018 #include "util/log.hpp"
00019 
00020 #include <iostream>
00021 
00022 #include "math/rectf.hpp"
00023 #include "supertux/console.hpp"
00024 
00025 static std::ostream& get_logging_instance (void)
00026 {
00027   if (Console::instance != NULL)
00028     return (Console::output);
00029   else
00030     return (std::cerr);
00031 }
00032 
00033 static std::ostream& log_generic_f (const char *prefix, const char* file, int line)
00034 {
00035   get_logging_instance () << prefix << " " << file << ":" << line << " ";
00036   return (get_logging_instance ());
00037 }
00038 
00039 std::ostream& log_debug_f(const char* file, int line) 
00040 {
00041   return (log_generic_f ("[DEBUG]", file, line));
00042 }
00043 
00044 std::ostream& log_info_f(const char* file, int line) 
00045 {
00046   return (log_generic_f ("[INFO]", file, line));
00047 }
00048 
00049 std::ostream& log_warning_f(const char* file, int line) 
00050 {
00051   return (log_generic_f ("[WARNING]", file, line));
00052 }
00053 
00054 std::ostream& log_fatal_f(const char* file, int line) 
00055 {
00056   return (log_generic_f ("[FATAL]", file, line));
00057 }
00058 
00059 std::ostream& operator<<(std::ostream& out, const Vector& vector)
00060 {
00061   out << '[' << vector.x << ',' << vector.y << ']';
00062   return out;
00063 }
00064 
00065 std::ostream& operator<<(std::ostream& out, const Rectf& rect)
00066 {
00067   out << "[" << rect.get_left() << "," << rect.get_top() << "   "
00068       << rect.get_right() << "," << rect.get_bottom() << "]";
00069   return out;
00070 }
00071 
00072 /* EOF */

Generated on Mon Jun 9 03:38:23 2014 for SuperTux by  doxygen 1.5.1