00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
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