logger.h

Go to the documentation of this file.
00001 /*
00002 **  ClanLib SDK
00003 **  Copyright (c) 1997-2011 The ClanLib Team
00004 **
00005 **  This software is provided 'as-is', without any express or implied
00006 **  warranty.  In no event will the authors be held liable for any damages
00007 **  arising from the use of this software.
00008 **
00009 **  Permission is granted to anyone to use this software for any purpose,
00010 **  including commercial applications, and to alter it and redistribute it
00011 **  freely, subject to the following restrictions:
00012 **
00013 **  1. The origin of this software must not be misrepresented; you must not
00014 **     claim that you wrote the original software. If you use this software
00015 **     in a product, an acknowledgment in the product documentation would be
00016 **     appreciated but is not required.
00017 **  2. Altered source versions must be plainly marked as such, and must not be
00018 **     misrepresented as being the original software.
00019 **  3. This notice may not be removed or altered from any source distribution.
00020 **
00021 **  Note: Some of the libraries ClanLib may link to may have additional
00022 **  requirements or restrictions.
00023 **
00024 **  File Author(s):
00025 **
00026 **    Magnus Norddahl
00027 */
00028 
00031 
00032 #pragma once
00033 
00034 #include "../api_core.h"
00035 #include "string_format.h"
00036 #include "string_help.h"
00037 #include "../System/mutex.h"
00038 
00042 class CL_API_CORE CL_Logger
00043 {
00046 
00047 public:
00049         CL_Logger();
00050 
00051         virtual ~CL_Logger();
00052 
00056 
00057 public:
00059         static std::vector<CL_Logger*> instances;
00060 
00062         static CL_Mutex mutex;
00063 
00067 
00068 public:
00070         void enable();
00071 
00073         void disable();
00074 
00076         virtual void log(const CL_StringRef &type, const CL_StringRef &text);
00077 
00081 
00082 private:
00084 };
00085 
00089 CL_API_CORE void cl_log_event(const CL_StringRef &type, const CL_StringRef &text);
00090 
00091 template <class Arg1>
00092 void cl_log_event(const CL_StringRef &type, const CL_StringRef &format, Arg1 arg1)
00093 { CL_StringFormat f(format); f.set_arg(1, arg1); cl_log_event(type, f.get_result()); }
00094 
00095 template <class Arg1, class Arg2>
00096 void cl_log_event(const CL_StringRef &type, const CL_StringRef &format, Arg1 arg1, Arg2 arg2)
00097 { CL_StringFormat f(format); f.set_arg(1, arg1); f.set_arg(2, arg2); cl_log_event(type, f.get_result()); }
00098 
00099 template <class Arg1, class Arg2, class Arg3>
00100 void cl_log_event(const CL_StringRef &type, const CL_StringRef &format, Arg1 arg1, Arg2 arg2, Arg3 arg3)
00101 { CL_StringFormat f(format); f.set_arg(1, arg1); f.set_arg(2, arg2); f.set_arg(3, arg3); cl_log_event(type, f.get_result()); }
00102 
00103 template <class Arg1, class Arg2, class Arg3, class Arg4>
00104 void cl_log_event(const CL_StringRef &type, const CL_StringRef &format, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4)
00105 { CL_StringFormat f(format); f.set_arg(1, arg1); f.set_arg(2, arg2); f.set_arg(3, arg3); f.set_arg(4, arg4); cl_log_event(type, f.get_result()); }
00106 
00107 template <class Arg1, class Arg2, class Arg3, class Arg4, class Arg5>
00108 void cl_log_event(const CL_StringRef &type, const CL_StringRef &format, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5)
00109 { CL_StringFormat f(format); f.set_arg(1, arg1); f.set_arg(2, arg2); f.set_arg(3, arg3); f.set_arg(4, arg4); f.set_arg(5, arg5); cl_log_event(type, f.get_result()); }
00110 
00111 template <class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6>
00112 void cl_log_event(const CL_StringRef &type, const CL_StringRef &format, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6)
00113 { CL_StringFormat f(format); f.set_arg(1, arg1); f.set_arg(2, arg2); f.set_arg(3, arg3); f.set_arg(4, arg4); f.set_arg(5, arg5); f.set_arg(6, arg6); cl_log_event(type, f.get_result()); }
00114 
00115 template <class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Arg7>
00116 void cl_log_event(const CL_StringRef &type, const CL_StringRef &format, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6, Arg7 arg7)
00117 { CL_StringFormat f(format); f.set_arg(1, arg1); f.set_arg(2, arg2); f.set_arg(3, arg3); f.set_arg(4, arg4); f.set_arg(5, arg5); f.set_arg(6, arg6); f.set_arg(7, arg7); cl_log_event(type, f.get_result()); }
00118