gwnavruntime/basesystem/logger.h Source File

logger.h
Go to the documentation of this file.
1 /*
2 * Copyright 2016 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 #pragma once
8 
12 
13 namespace Kaim
14 {
15 
16 struct LogWrapper
17 {
18  LogWrapper(LogMessageId id) : m_id(id) {}
19  void Print(const char* fmt, ...) const KY_LOG_VAARG_ATTRIBUTE(2,3);
20  LogMessageId m_id;
21 };
22 
23 }
24 
25 #ifndef KY_NO_LOG_OUTPUT
26 
27  #ifdef KY_CC_MSVC
28  #define KY_LOG_ADD_LN(fmt, ...) (fmt "\n", __VA_ARGS__)
29  #else
30  #define KY_LOG_ADD_LN(fmt, ...) (fmt "\n", ## __VA_ARGS__)
31  #endif
32  #define KY_LOG_SUFFIX_LN(args) KY_LOG_ADD_LN args
33 
34  // To log in DEBUG/RELEASE but not in SHIPPING
35  // KY_LOG_MESSAGE(("x = %d", x)); log "Warning: x = 55\n"
36  // KY_LOG_WARNING(("x = %d", x)); log "Warning: x = 55 [myfile.cpp:89]\n"
37  // KY_LOG_ERROR(("x = %d", x)); log "Error: x = 55 [myfile.cpp:89]\n"
38  #define KY_LOG_MESSAGE(args) KY_MACRO_START Kaim::LogWrapper(Kaim::Log_Message).Print KY_LOG_SUFFIX_LN(args); KY_MACRO_END
39  #define KY_LOG_WARNING(args) KY_MACRO_START Kaim::LogWrapper(Kaim::Log_Warning).Print KY_LOG_SUFFIX(args); KY_MACRO_END
40  #define KY_LOG_ERROR(args) KY_MACRO_START Kaim::LogWrapper(Kaim::Log_Error).Print KY_LOG_SUFFIX(args); KY_MACRO_END
41 
42  #define KY_LOG_MESSAGE_IF(condition, args) KY_MACRO_START if (condition) { KY_LOG_MESSAGE(args); } KY_MACRO_END
43  #define KY_LOG_WARNING_IF(condition, args) KY_MACRO_START if (condition) { KY_LOG_WARNING(args); } KY_MACRO_END
44  #define KY_LOG_ERROR_IF(condition, args) KY_MACRO_START if (condition) { KY_LOG_ERROR(args); } KY_MACRO_END
45 
46  #define KY_REPORT_WEIRD_CASE(args) KY_MACRO_START { KY_LOG_ERROR(args);} KY_MACRO_END
47 
48 #else
49  #define KY_LOG_MESSAGE(args) ((void)0)
50  #define KY_LOG_WARNING(args) ((void)0)
51  #define KY_LOG_ERROR(args) ((void)0)
52 
53  #define KY_LOG_MESSAGE_IF(condition, args) ((void)0)
54  #define KY_LOG_WARNING_IF(condition, args) ((void)0)
55  #define KY_LOG_ERROR_IF(condition, args) ((void)0)
56 
57  #define KY_REPORT_WEIRD_CASE(args) ((void)0)
58 #endif
59 
60 
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17