gwnavruntime/basesystem/logger.h Source File

logger.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_Logger_H
9 #define Navigation_Logger_H
10 
14 
15 namespace Kaim
16 {
17 
18 class LogWrapper
19 {
20 public:
21  LogWrapper(LogMessageId id) : m_id(id) {}
22 
23  void Print(const char* fmt, ...) const KY_LOG_VAARG_ATTRIBUTE(2,3);
24 
25 private:
26  LogMessageId m_id;
27 };
28 
29 }
30 
31 #define KY_LOG_BIG_TITLE_BEGIN(prefix, title) \
32  prefix << "==============================================================\n" \
33  << prefix << "======== " << title << "\n\n"
34 
35 #define KY_LOG_BIG_TITLE_END(prefix, title) \
36  prefix << "======== " << title << "\n" \
37  << prefix << "==============================================================\n\n"
38 
39 #define KY_LOG_SMALL_TITLE_BEGIN(prefix, title) \
40  prefix << "------------------------------------------------------\n" \
41  << prefix << "---- " << title << "\n"
42 
43 #define KY_LOG_SMALL_TITLE_END(prefix, title) \
44  prefix << "---- " << title << "\n" \
45  << prefix << "------------------------------------------------------\n\n"
46 
47 
48 
49 
50 #ifndef KY_NO_LOG_OUTPUT
51 
52  // To log in DEBUG/RELEASE but not in SHIPPING
53  // usage KY_LOG_XXX(("x = %d; y = %d", x, y));
54  // KY_LOG_TEXT: prefix="" , suffix=""
55  // KY_LOG_MESSAGE: prefix="" , suffix=" [__FILE__:__LINE__]\n"
56  // KY_LOG_WARNING: prefix="Warning: ", suffix=" [__FILE__:__LINE__]\n"
57  // KY_LOG_ERROR: prefix="Error: " , suffix=" [__FILE__:__LINE__]\n"
58  #define KY_LOG_TEXT(args) KY_MACRO_START Kaim::LogWrapper(Kaim::Log_Message).Print args; KY_MACRO_END
59  #define KY_LOG_MESSAGE(args) KY_MACRO_START Kaim::LogWrapper(Kaim::Log_Message).Print KY_LOG_SUFFIX(args); KY_MACRO_END
60  #define KY_LOG_WARNING(args) KY_MACRO_START Kaim::LogWrapper(Kaim::Log_Warning).Print KY_LOG_SUFFIX(args); KY_MACRO_END
61  #define KY_LOG_ERROR(args) KY_MACRO_START Kaim::LogWrapper(Kaim::Log_Error).Print KY_LOG_SUFFIX(args); KY_MACRO_END
62 
63  // usage KY_LOG_OUTPUT((logMessageId ,"x = %d; y = %d", x, y))
64  // where logMessageId is of LogMessageId, this will command prefix and suffix used, and it allows to specify your own channel
65  #define KY_LOG_OUTPUT(id, args) KY_MACRO_START Kaim::LogWrapper(id).Print args; KY_MACRO_END
66 
67 
68  #define KY_LOG_TEXT_IF(condition, args) KY_MACRO_START if (condition) { KY_LOG_TEXT(args); } KY_MACRO_END
69  #define KY_LOG_MESSAGE_IF(condition, args) KY_MACRO_START if (condition) { KY_LOG_MESSAGE(args); } KY_MACRO_END
70  #define KY_LOG_WARNING_IF(condition, args) KY_MACRO_START if (condition) { KY_LOG_WARNING(args); } KY_MACRO_END
71  #define KY_LOG_ERROR_IF(condition, args) KY_MACRO_START if (condition) { KY_LOG_ERROR(args); } KY_MACRO_END
72  #define KY_LOG_OUTPUT_IF(condition, id, args) KY_MACRO_START if (condition) { KY_LOG_OUTPUT(id, args); } KY_MACRO_END
73 #else
74  #define KY_LOG_TEXT(args) ((void)0)
75  #define KY_LOG_MESSAGE(args) ((void)0)
76  #define KY_LOG_WARNING(args) ((void)0)
77  #define KY_LOG_ERROR(args) ((void)0)
78  #define KY_LOG_OUTPUT(args, id) ((void)0)
79 
80  #define KY_LOG_TEXT_IF(condition, args) ((void)0)
81  #define KY_LOG_MESSAGE_IF(condition, args) ((void)0)
82  #define KY_LOG_WARNING_IF(condition, args) ((void)0)
83  #define KY_LOG_ERROR_IF(condition, args) ((void)0)
84  #define KY_LOG_OUTPUT_IF(condition, id, args) ((void)0)
85 
86 #endif
87 
88 
89 #endif //Navigation_Logger_H
Definition: gamekitcrowddispersion.h:20