summaryrefslogtreecommitdiff
path: root/src/binder/inc/bindinglog.hpp
blob: b2917f80dd1bb61b1156d5e4a58859338499917f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
// ============================================================
//
// BindingLog.hpp
//


//
// Defines the BindingLog class
//
// ============================================================

#ifndef __BINDER__BINDING_LOG_HPP__
#define __BINDER__BINDING_LOG_HPP__

#include "bindertypes.hpp"

namespace BINDER_SPACE
{
    class BindingLog
    {
    public:
        BindingLog();
        ~BindingLog();

        //
        // These functions will create a new log together with pre-bind state
        // information if needed and store it into the application context.
        // This is to avoid endlessly passing around the debug log.
        //
        static HRESULT CreateInContext(/* in */ ApplicationContext *pApplicationContext,
                                       /* in */ SString            &assemblyPath,
                                       /* in */ PEAssembly         *pParentAssembly);
        static HRESULT CreateInContext(/* in */ ApplicationContext *pApplicationContext,
                                       /* in */ AssemblyName       *pAssemblyName,
                                       /* in */ PEAssembly         *pParentAssembly);

        HRESULT Log(SString &info);

        inline HRESULT Log(LPCWSTR pwzInfo);
        inline HRESULT Log(/* in */ LPCWSTR pwzPrefix,
                           /* in */ SString &info);

        HRESULT LogAssemblyName(/* in */ LPCWSTR       pwzPrefix,
                                /* in */ AssemblyName *pAssemblyName);

        HRESULT LogHR(/* in */ HRESULT logHR);
        HRESULT LogResult(/* in */ BindResult *pBindResult);

        HRESULT Flush();

        inline BOOL CanLog();

        void SetDebugLog(CDebugLog *pCDebugLog);

    protected:
        static BOOL IsLoggingNeeded();

        static HRESULT CreateInContext(/* in */ ApplicationContext *pApplicationContext,
                                       /* in */ AssemblyName       *pAssemblyName,
                                       /* in */ SString            &assemblyPath,
                                       /* in */ PEAssembly         *pParentAssembly);

        HRESULT LogPreBindState(/* in */ ApplicationContext *pApplicationContext,
                                /* in */ AssemblyName       *pAssemblyName,
                                /* in */ SString            &assemblyPath,
                                /* in */ PEAssembly         *pParentAssembly);


        inline CDebugLog *GetDebugLog();

        HRESULT LogUser();

        CDebugLog *m_pCDebugLog;
    };

#include "bindinglog.inl"
};

#endif