ZFFramework
 
Loading...
Searching...
No Matches
ZFLog.h
Go to the documentation of this file.
1
5
6#ifndef _ZFI_ZFLog_h_
7#define _ZFI_ZFLog_h_
8
9#include "ZFLogLevel.h"
10#include "ZFMutex.h"
11#include "ZFOutputForFormat.h"
13
14// ============================================================
22
23
24typedef zfstring (*ZFLogHeaderFunc)(ZF_IN const ZFCallerInfo &callerInfo);
37
44
45// ============================================================
77#define ZFLog(...) _ZFP_ZFLog((ZFLogHeader ? ZFLogHeader(ZFCallerInfoCreate()).cString() : zfnull), zfstr(__VA_ARGS__))
78
80#define ZFLogTrim(...) _ZFP_ZFLog(zfnull, zfstr(__VA_ARGS__))
81
82extern ZFLIB_ZFCore ZFOutput _ZFP_ZFLog(
83 ZF_IN const zfchar *header
84 , ZF_IN_OPT const zfchar *text = zfnull
85 );
86
87// ============================================================
91zfclass ZFLIB_ZFCore ZFLogFormat : zfextend ZFObject, zfimplement ZFOutputFormat {
92 ZFOBJECT_DECLARE(ZFLogFormat, ZFObject)
93 ZFIMPLEMENT_DECLARE(ZFOutputFormat)
94
95public:
98
99protected:
101 virtual void format(
103 , ZF_IN ZFOutputFormatStep outputStep
104 , ZF_IN const zfchar *src
105 , ZF_IN zfindex srcLen
106 );
107};
108
113 , ZFMP_IN(ZFLogFormat *, fmt)
119
120// ============================================================
121// other convenient method
122extern ZFLIB_ZFCore zfstring _ZFP_ZFLogCurTimeString(void);
124#define ZFLogCurTimeString() _ZFP_ZFLogCurTimeString()
130
132#endif // #ifndef _ZFI_ZFLog_h_
133
#define ZFLIB_ZFCore
used to export symbols
Definition ZFCoreEnvDef.h:30
_ZFT_t_zfchar zfchar
char wrapper
Definition ZFCoreTypeDef_CharType.h:17
#define zfextend
dummy macro shows class inherit from another
Definition ZFCoreTypeDef_ClassType.h:53
#define zfoverride
dummy macro shows that method override parent's method
Definition ZFCoreTypeDef_ClassType.h:58
#define ZF_IN
dummy macro that shows the param used as required input
Definition ZFCoreTypeDef_ClassType.h:180
#define ZF_IN_OPT
dummy macro that shows the param used as optional input
Definition ZFCoreTypeDef_ClassType.h:184
#define ZF_IN_OUT
dummy macro that shows the param used as required input and output
Definition ZFCoreTypeDef_ClassType.h:196
_ZFT_t_zfbool zfbool
bool type
Definition ZFCoreTypeDef_CoreType.h:103
_ZFT_t_zfindex zfindex
similar to size_t, used for index and size only
Definition ZFCoreTypeDef_CoreType.h:154
#define zftrue
bool true type
Definition ZFCoreTypeDef_CoreType.h:107
#define zfnull
same as NULL, defined for future use
Definition ZFCoreTypeDef_CoreType.h:88
zft_zfstring< zfchar > zfstring
see zft_zfstring
Definition ZFCoreTypeDef_StringType.h:15
#define ZFEXPORT_VAR_DECLARE(ZFLIB_, Type, Name)
util to export global variable
Definition ZFExport.h:68
zfbool & ZFLogHeaderDefault_logTime(void)
see ZFLogHeader, enabled by default
Definition ZFLog.h:41
void ZFLogFormatDefault(ZFLogFormat *fmt)
change default log format
zfstring ZFLogHeaderDefault(const ZFCallerInfo &callerInfo)
see ZFLogHeader
zfstring(* ZFLogHeaderFunc)(const ZFCallerInfo &callerInfo)
see ZFLogHeader
Definition ZFLog.h:24
zfbool & ZFLogHeaderDefault_logCaller(void)
see ZFLogHeader, enabled by default, set to false if v_ZFLogLevel::e_Verbose is not active
Definition ZFLog.h:43
ZFMutex * ZFLogMutex()
mutex used by ZFLog, you may use this lock to prevent your log actions from being interrupted
ZFLogHeaderFunc ZFLogHeader
callback to obtain log header for ZFLog
zfstring ZFLogCurTimeString()
get a string contains current time with format HH:mm:ss.SSS
log level define
#define ZFMP_IN(ParamType, paramName)
macro to wrap param types for ZFMETHOD_INLINE_0 series
Definition ZFMethod.h:105
#define ZFMETHOD_FUNC_DECLARE_0(ZFLIB_, ReturnType, MethodName)
declare function type of ZFMethod
Definition ZFMethodFuncDeclare.h:493
#define ZFMETHOD_FUNC_DECLARE_1(ZFLIB_, ReturnType, MethodName, ZFMP_0)
see ZFMETHOD_FUNC_DECLARE_0
Definition ZFMethodFuncDeclare.h:624
mutex utility
#define ZF_NAMESPACE_GLOBAL_BEGIN
begin namespace ZFFramework
Definition ZFNamespace.h:97
#define ZF_NAMESPACE_GLOBAL_END
end namespace ZFFramework
Definition ZFNamespace.h:98
#define zfclass
same as class, shows that this class is a ZFObject type
Definition ZFObjectClassTypeFwd.h:38
#define ZFOBJECT_DECLARE(ChildClass, SuperClass,...)
necessary for every class inherit from ZFObject
Definition ZFObjectDeclare.h:126
#define ZFIMPLEMENT_DECLARE(ImplementedInterfaces,...)
see ZFINTERFACE_DECLARE
Definition ZFObjectInterface.h:169
#define zfimplement
shows class implement from interface, see ZFInterface
Definition ZFObjectInterface.h:24
output callback util
v_ZFOutputFormatStep::ZFEnumType ZFOutputFormatStep
see v_ZFOutputFormatStep
Definition ZFOutputForFormat.h:36
#define ZFPROPERTY_ASSIGN(Type, Name,...)
see ZFPROPERTY_RETAIN
Definition ZFPropertyDeclare.h:128
util class to hold caller info
Definition ZFCallerInfo.h:63
output format for ZFLog
Definition ZFLog.h:91
virtual void format(zfstring &ret, ZFOutputFormatStep outputStep, const zfchar *src, zfindex srcLen)
see ZFOutputForFormat
virtual zfbool & autoEndl()
whether auto append endl for each ZFLog call
Definition ZFLog.h:97
mutex utility
Definition ZFMutex.h:15
general output callback
Definition ZFIOCallback_output.h:37