Line data Source code
1 : /*
2 : * If not stated otherwise in this file or this component's LICENSE file the
3 : * following copyright and licenses apply:
4 : *
5 : * Copyright 2024 Sky UK
6 : *
7 : * Licensed under the Apache License, Version 2.0 (the "License");
8 : * you may not use this file except in compliance with the License.
9 : * You may obtain a copy of the License at
10 : *
11 : * http://www.apache.org/licenses/LICENSE-2.0
12 : *
13 : * Unless required by applicable law or agreed to in writing, software
14 : * distributed under the License is distributed on an "AS IS" BASIS,
15 : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 : * See the License for the specific language governing permissions and
17 : * limitations under the License.
18 : */
19 :
20 : #ifndef FIREBOLT_RIALTO_I_CLIENT_LOG_CONTROL_H_
21 : #define FIREBOLT_RIALTO_I_CLIENT_LOG_CONTROL_H_
22 :
23 : /**
24 : * @file IClientLogControl.h
25 : *
26 : * The definition of the IClientLogControl interface.
27 : *
28 : * Via this interface the logging of the Rialto Client can
29 : * be redirected to a user specified call handler
30 : */
31 :
32 : #include <memory>
33 : #include <stdint.h>
34 :
35 : #include "ControlCommon.h"
36 : #include "IClientLogHandler.h"
37 : #include "IControlClient.h"
38 :
39 : namespace firebolt::rialto
40 : {
41 : class IClientLogControl;
42 :
43 : /**
44 : * @brief IClientLogControl factory class, returns a concrete implementation of IClientLogControl
45 : */
46 : class IClientLogControlFactory
47 : {
48 : public:
49 8 : IClientLogControlFactory() = default;
50 8 : virtual ~IClientLogControlFactory() = default;
51 :
52 : /**
53 : * @brief Creates the IClientLogControlFactory
54 : *
55 : * @retval the factory instance or null on error.
56 : */
57 : static std::shared_ptr<IClientLogControlFactory> createFactory();
58 :
59 : /**
60 : * @brief IClientLogControl factory method, returns a concrete singleton implementation of IClientLogControl
61 : *
62 : * @retval the new IClientLogControl instance or null on error.
63 : */
64 : virtual IClientLogControl &createClientLogControl() = 0;
65 : };
66 :
67 : /**
68 : * @brief The definition of the IClientLogControl interface.
69 : *
70 : * This interface defines the public API for controlling Rialto client's
71 : * log handling. This class is a singleton
72 : *
73 : */
74 : class IClientLogControl
75 : {
76 : public:
77 1 : IClientLogControl() = default;
78 1 : virtual ~IClientLogControl() = default;
79 :
80 : IClientLogControl(const IClientLogControl &) = delete;
81 : IClientLogControl &operator=(const IClientLogControl &) = delete;
82 : IClientLogControl(IClientLogControl &&) = delete;
83 : IClientLogControl &operator=(IClientLogControl &&) = delete;
84 :
85 : /**
86 : * @brief Register a new log handler
87 : *
88 : * @param[in] handler : The user can pass in an object that will henceforth
89 : * receive callbacks to it's log(...) method for rialto client log events.
90 : * Please see IClientLogHandler for the parameters that log() must accept.
91 : * To cancel callbacks then call this method again but pass a nullptr for
92 : * the handler.
93 : * @param[in] ignoreLogLevels : If true then the handler will receive ALL log level messages regardless of the
94 : * currently configured log level
95 : *
96 : * @retval true if successful
97 : */
98 : virtual bool registerLogHandler(const std::shared_ptr<IClientLogHandler> &handler, bool ignoreLogLevels) = 0;
99 : };
100 :
101 : }; // namespace firebolt::rialto
102 :
103 : #endif // FIREBOLT_RIALTO_I_CLIENT_LOG_CONTROL_H_
|