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 "ZFOutputForFormat.h"
12
13// ============================================================
21
22
23typedef zfstring (*ZFLogHeaderFunc)(ZF_IN const ZFCallerInfo &callerInfo);
36
43
44// ============================================================
76#define ZFLog(...) _ZFP_ZFLog((ZFLogHeader ? ZFLogHeader(ZFCallerInfoCreate()).cString() : zfnull), zfstr(__VA_ARGS__))
77
79#define ZFLogTrim(...) _ZFP_ZFLog(zfnull, zfstr(__VA_ARGS__))
80
81extern ZFLIB_ZFCore ZFOutput _ZFP_ZFLog(
82 ZF_IN const zfchar *header
83 , ZF_IN_OPT const zfchar *text = zfnull
84 );
85
86// ============================================================
90zfclass ZFLIB_ZFCore ZFLogFormat : zfextend ZFOutputFormat {
91 ZFOBJECT_DECLARE(ZFLogFormat, ZFOutputFormat)
92
93public:
96
97protected:
99 virtual void format(
101 , ZF_IN ZFOutputFormatStep outputStep
102 , ZF_IN const zfchar *src
103 , ZF_IN zfindex srcLen
104 );
105};
106
111 , ZFMP_IN(ZFLogFormat *, fmt)
117
118// ============================================================
119// other convenient method
120extern ZFLIB_ZFCore zfstring _ZFP_ZFLogCurTimeString(void);
122#define ZFLogCurTimeString() _ZFP_ZFLogCurTimeString()
128
130#endif // #ifndef _ZFI_ZFLog_h_
131
#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:184
#define ZF_IN_OPT
dummy macro that shows the param used as optional input
Definition ZFCoreTypeDef_ClassType.h:188
#define ZF_IN_OUT
dummy macro that shows the param used as required input and output
Definition ZFCoreTypeDef_ClassType.h:200
_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:40
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:23
ZFObject * ZFLogMutex()
mutex used by ZFLog, you may use this lock to prevent your log actions from being interrupted
zfbool & ZFLogHeaderDefault_logCaller(void)
see ZFLogHeader, enabled by default, set to false if v_ZFLogLevel::e_Verbose is not active
Definition ZFLog.h:42
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
#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
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:127
util class to hold caller info
Definition ZFCallerInfo.h:63
output format for ZFLog
Definition ZFLog.h:90
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:95
base class of all objects
Definition ZFObjectCore.h:196
general output callback
Definition ZFIOCallback_output.h:37