ZFFramework
 
Loading...
Searching...
No Matches
zfimplLog.h
Go to the documentation of this file.
1
5
6#ifndef _ZFI_zfimplLog_h_
7#define _ZFI_zfimplLog_h_
8
9#include "ZFNamespace.h"
10
12
13#ifndef zfimplLog
14 #if (defined(ANDROID) || defined(__ANDROID__))
15 #include <jni.h>
16 #include <android/log.h>
17 #define zfimplLog(fmt, ...) \
18 ((void)__android_log_print(ANDROID_LOG_ERROR, "JNILog", fmt, ##__VA_ARGS__))
19 #elif (defined(QT_VERSION) || defined(QT_CORE_LIB))
20 #include <QDebug>
21 #define zfimplLog(fmt, ...) \
22 qDebug(fmt, ##__VA_ARGS__)
23 #else
24 #include <cstdio>
25 #define zfimplLog(fmt, ...) \
26 do { \
27 printf(fmt, ##__VA_ARGS__); \
28 printf("\n"); \
29 fflush(stdout); \
30 } while(false)
31 #endif
32#endif
33
34#ifndef zfimplUniqueName
35 #define zfimplUniqueName(name) _ZFP_zfimplUniqueName2(name, __LINE__)
36 #define _ZFP_zfimplUniqueName2(name, line) _ZFP_zfimplUniqueName3(name, line)
37 #define _ZFP_zfimplUniqueName3(name, line) _ZFP_uniq_##name##_##line
38#endif
39
40// ============================================================
41#ifndef zfimplTimestamp
42 #define zfimplTimestamp() _ZFP_zfimplTimestamp()
43#endif
44extern ZFLIB_ZFCore long long _ZFP_zfimplTimestamp(void);
45
46#ifndef zfimplInvokeTimeLogger
47 #define zfimplInvokeTimeLogger(hint, ...) \
48 _ZFP_zfimplInvokeTimeLogger zfimplUniqueName(ivkTime)(0, hint, ##__VA_ARGS__)
49 #define zfimplInvokeTimeLoggerWithCost(cost, hint, ...) \
50 _ZFP_zfimplInvokeTimeLogger zfimplUniqueName(ivkTime)(cost, hint, ##__VA_ARGS__)
51#endif
52class ZFLIB_ZFCore _ZFP_zfimplInvokeTimeLogger {
53public:
54 _ZFP_zfimplInvokeTimeLogger(int cond, const char *hint, ...);
55 ~_ZFP_zfimplInvokeTimeLogger(void);
56private:
57 char _hint[512];
58 long long _lastTime;
59 int _cond;
60};
61
62// ============================================================
63#ifndef zfimplTime
64 #define zfimplTime() ((const char *)_ZFP_zfimplTime().buf)
65#endif
66class ZFLIB_ZFCore _ZFP_zfimplTimeStr {
67public:
68 char buf[32];
69};
70extern ZFLIB_ZFCore _ZFP_zfimplTimeStr _ZFP_zfimplTime(void);
71
73#endif // #ifndef _ZFI_zfimplLog_h_
74
#define ZFLIB_ZFCore
used to export symbols
Definition ZFCoreEnvDef.h:30
global namespace define