gwnavruntime/basesystem/logstream.h Source File

logstream.h
Go to the documentation of this file.
1 /*
2 * Copyright 2015 Autodesk, Inc. All rights reserved.
3 * Use of this software is subject to the terms of the Autodesk license agreement and any attachments or Appendices thereto provided at the time of installation or download,
4 * or which otherwise accompanies this software in either electronic or hard copy form, or which is signed by you and accepted by Autodesk.
5 */
6 
7 // primary contact: GUAL - secondary contact: NOBODY
8 #ifndef Navigation_LogStream_H
9 #define Navigation_LogStream_H
10 
12 
13 namespace Kaim
14 {
15 
16 static const char Endl = '\n';
17 
18 // LogStream useful to print to log with << sematics, usage:
19 // LogStream stream;
20 // stream << "x=" << x << "\n";
21 class LogStream
22 {
23  KY_DEFINE_NEW_DELETE_OPERATORS(Kaim::Stat_Default_Mem)
24 public:
25 #ifndef KY_NO_LOG_OUTPUT
26  template <typename T>
27  LogStream& Log(const char* format, const T& value)
28  {
30  Kaim::BaseLog::GetGlobalBaseLog()->LogMessage(format, value);
31  return *this;
32  }
33 #endif
34 };
35 
36 
37 #ifndef KY_NO_LOG_OUTPUT
38  inline LogStream& operator<<(LogStream& s, KyInt32 value) { return s.Log("%i", value); }
39  inline LogStream& operator<<(LogStream& s, KyUInt32 value) { return s.Log("%u", value); }
40  inline LogStream& operator<<(LogStream& s, KyInt64 value) { return s.Log("%i", (KyInt32)value); }
41  inline LogStream& operator<<(LogStream& s, KyUInt64 value) { return s.Log("%u", (KyUInt32)value); }
42  inline LogStream& operator<<(LogStream& s, float value) { return s.Log("%f", value); }
43  inline LogStream& operator<<(LogStream& s, double value) { return s.Log("%f", value); }
44  inline LogStream& operator<<(LogStream& s, bool value) { return value ? s.Log("%s", "true") : s.Log("%s", "false"); }
45  inline LogStream& operator<<(LogStream& s, char value) { return s.Log("%c", value); }
46  inline LogStream& operator<<(LogStream& s, const char* str) { return s.Log("%s", str); }
47 #else
48  inline LogStream& operator<<(LogStream& s, KyInt32 value) { KY_UNUSED(value); return s; }
49  inline LogStream& operator<<(LogStream& s, KyUInt32 value) { KY_UNUSED(value); return s; }
50  inline LogStream& operator<<(LogStream& s, KyInt64 value) { KY_UNUSED(value); return s; }
51  inline LogStream& operator<<(LogStream& s, KyUInt64 value) { KY_UNUSED(value); return s; }
52  inline LogStream& operator<<(LogStream& s, float value) { KY_UNUSED(value); return s; }
53  inline LogStream& operator<<(LogStream& s, double value) { KY_UNUSED(value); return s; }
54  inline LogStream& operator<<(LogStream& s, bool value) { KY_UNUSED(value); return s; }
55  inline LogStream& operator<<(LogStream& s, char value) { KY_UNUSED(value); return s; }
56  inline LogStream& operator<<(LogStream& s, const char* str) { KY_UNUSED(str); return s; }
57 #endif
58 
59 }
60 
61 #endif // Navigation_LogStream_H
static BaseLog * GetGlobalBaseLog()
BaseLog static functions must be used instead of Log::
Definition: baselog.h:33
int KyInt32
Type used internally to represent a 32-bit integer.
Definition: types.h:35
unsigned __int64 KyUInt64
Type used internally to represent an unsigned 64-bit integer.
Definition: types.h:38
Definition: gamekitcrowddispersion.h:20
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
__int64 KyInt64
Type used internally to represent a 64-bit integer.
Definition: types.h:37