1// Licensed to the .NET Foundation under one or more agreements.
2// The .NET Foundation licenses this file to you under the MIT license.
3// See the LICENSE file in the project root for more information.
4// ============================================================
5//
6// DebugLog.hpp
7//
8
9
10//
11// Defines the DebugLog class
12//
13// ============================================================
14
15#ifndef __BINDER__DEBUG_LOG_HPP__
16#define __BINDER__DEBUG_LOG_HPP__
17
18#include "bindertypes.hpp"
19#include "variables.hpp"
20
21namespace BINDER_SPACE
22{
23
24// When defined at the top of a source file, DISABLE_BINDER_DEBUG_LOGGING will cause
25// binder debug logging to be disabled only in the scope of that file by defining all the
26// binder logging macros as NOPs.
27
28#if defined(BINDER_DEBUG_LOG) && !defined(DISABLE_BINDER_DEBUG_LOGGING)
29
30#define BINDER_LOG_STARTUP() \
31 IF_FAIL_GO(DebugLog::Startup());
32
33#define BINDER_LOG_LOCK() \
34 CRITSEC_Holder logLock(g_BinderVariables->m_logCS);
35
36#define BINDER_LOG_ENTER(scope) \
37 DebugLog::Enter(scope);
38
39#define BINDER_LOG_LEAVE(scope) \
40 DebugLog::Leave(scope);
41
42#define BINDER_LOG_LEAVE_HR(scope, hr) \
43 DebugLog::LeaveHR(scope, hr);
44
45#define BINDER_LOG_LEAVE_BOOL(scope, fResult) \
46 DebugLog::LeaveBool(scope, fResult);
47
48#define BINDER_LOG(comment) \
49 DebugLog::Log(comment);
50
51#define BINDER_LOG_STRING(comment, value) \
52 DebugLog::Log(comment, value);
53
54#define BINDER_LOG_HRESULT(comment, hr) \
55 DebugLog::Log(comment, hr);
56
57#define BINDER_LOG_ASSEMBLY_NAME(comment, assemblyName) \
58 DebugLog::Log(comment, assemblyName);
59
60#define BINDER_LOG_I_ASSEMBLY_NAME(comment, assemblyName) \
61 DebugLog::Log(comment, assemblyName);
62
63#define BINDER_LOG_POINTER(comment, pData) \
64 DebugLog::Log(comment, (void *) (pData));
65
66 class DebugLog
67 {
68 public:
69 static HRESULT Startup();
70
71 static void Enter(/* in */ WCHAR *pwzScope);
72 static void Leave(/* in */ WCHAR *pwzScope);
73 static void LeaveHR(/* in */ WCHAR *pwzScope,
74 /* in */ HRESULT hrLog);
75 static void LeaveBool(/* in */ WCHAR *pwzScope,
76 /* in */ BOOL fResult);
77
78 static void Log(/* in */ WCHAR *pwzComment);
79 static void Log(/* in */ WCHAR *pwzComment,
80 /* in */ SString &value);
81 static void Log(/* in */ WCHAR *pwzComment,
82 /* in */ const WCHAR *value);
83 static void Log(/* in */ WCHAR *pwzComment,
84 /* in */ HRESULT hrLog);
85 static void Log(/* in */ WCHAR *pwzComment,
86 /* in */ AssemblyName *pAssemblyName);
87 static void Log(/* in */ WCHAR *pwzComment,
88 /* in */ void *pData);
89 protected:
90 static void Log(/* in */ SString &info);
91 };
92#else
93 class DebugLog
94 {
95 public:
96 static void Empty() {};
97 };
98
99#define BINDER_LOG_STARTUP() DebugLog::Empty();
100
101#define BINDER_LOG_LOCK() DebugLog::Empty();
102
103#define BINDER_LOG_ENTER(scope) DebugLog::Empty();
104#define BINDER_LOG_LEAVE(scope) DebugLog::Empty();
105#define BINDER_LOG_LEAVE_HR(scope, hr) DebugLog::Empty();
106#define BINDER_LOG_LEAVE_BOOL(scope, fResult) DebugLog::Empty();
107
108#define BINDER_LOG(comment) DebugLog::Empty();
109#define BINDER_LOG_STRING(comment, value) DebugLog::Empty();
110#define BINDER_LOG_HRESULT(comment, hr) DebugLog::Empty();
111#define BINDER_LOG_ASSEMBLY_NAME(comment, assemblyName) DebugLog::Empty();
112#define BINDER_LOG_I_ASSEMBLY_NAME(comment, assemblyName) DebugLog::Empty();
113#define BINDER_LOG_POINTER(comment, pData) DebugLog::Empty();
114
115#endif
116};
117
118#endif
119