ClanLib  2.3.7
logger.h
Go to the documentation of this file.
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2011 The ClanLib Team
4 **
5 ** This software is provided 'as-is', without any express or implied
6 ** warranty. In no event will the authors be held liable for any damages
7 ** arising from the use of this software.
8 **
9 ** Permission is granted to anyone to use this software for any purpose,
10 ** including commercial applications, and to alter it and redistribute it
11 ** freely, subject to the following restrictions:
12 **
13 ** 1. The origin of this software must not be misrepresented; you must not
14 ** claim that you wrote the original software. If you use this software
15 ** in a product, an acknowledgment in the product documentation would be
16 ** appreciated but is not required.
17 ** 2. Altered source versions must be plainly marked as such, and must not be
18 ** misrepresented as being the original software.
19 ** 3. This notice may not be removed or altered from any source distribution.
20 **
21 ** Note: Some of the libraries ClanLib may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Magnus Norddahl
27 */
28 
31 
32 #pragma once
33 
34 #include "../api_core.h"
35 #include "string_format.h"
36 #include "string_help.h"
37 #include "../System/mutex.h"
38 
43 {
46 
47 public:
49  CL_Logger();
50 
51  virtual ~CL_Logger();
52 
56 
57 public:
59  static std::vector<CL_Logger*> instances;
60 
62  static CL_Mutex mutex;
63 
67 
68 public:
70  void enable();
71 
73  void disable();
74 
76  virtual void log(const CL_StringRef &type, const CL_StringRef &text);
77 
81 
82 private:
84 };
85 
89 CL_API_CORE void cl_log_event(const CL_StringRef &type, const CL_StringRef &text);
90 
91 template <class Arg1>
92 void cl_log_event(const CL_StringRef &type, const CL_StringRef &format, Arg1 arg1)
93 { CL_StringFormat f(format); f.set_arg(1, arg1); cl_log_event(type, f.get_result()); }
94 
95 template <class Arg1, class Arg2>
96 void cl_log_event(const CL_StringRef &type, const CL_StringRef &format, Arg1 arg1, Arg2 arg2)
97 { CL_StringFormat f(format); f.set_arg(1, arg1); f.set_arg(2, arg2); cl_log_event(type, f.get_result()); }
98 
99 template <class Arg1, class Arg2, class Arg3>
100 void cl_log_event(const CL_StringRef &type, const CL_StringRef &format, Arg1 arg1, Arg2 arg2, Arg3 arg3)
101 { 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()); }
102 
103 template <class Arg1, class Arg2, class Arg3, class Arg4>
104 void cl_log_event(const CL_StringRef &type, const CL_StringRef &format, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4)
105 { 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()); }
106 
107 template <class Arg1, class Arg2, class Arg3, class Arg4, class Arg5>
108 void cl_log_event(const CL_StringRef &type, const CL_StringRef &format, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5)
109 { 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()); }
110 
111 template <class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6>
112 void cl_log_event(const CL_StringRef &type, const CL_StringRef &format, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6)
113 { 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()); }
114 
115 template <class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Arg7>
116 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)
117 { 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()); }
118