• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef RDB_JSKIT_NAPI_RDB_LOG_OBSERVER_H
16 #define RDB_JSKIT_NAPI_RDB_LOG_OBSERVER_H
17 #include <memory>
18 
19 #include "js_uv_queue.h"
20 #include "napi/native_api.h"
21 #include "napi/native_common.h"
22 #include "napi/native_node_api.h"
23 #include "rdb_types.h"
24 
25 namespace OHOS {
26 namespace RelationalStoreJsKit {
27 class NapiLogObserver
28     : public DistributedRdb::SqlErrorObserver, public std::enable_shared_from_this<NapiLogObserver> {
29 public:
30     NapiLogObserver(napi_env env, napi_value callback, std::shared_ptr<AppDataMgrJsKit::UvQueue> uvQueue);
31     virtual ~NapiLogObserver();
32     void Clear();
33     bool operator==(napi_value value);
34     void OnErrorLog(const ExceptionMessage &exceptionMessage) override;
35 
36 private:
37     napi_env env_ = nullptr;
38     napi_ref callback_ = nullptr;
39     std::shared_ptr<AppDataMgrJsKit::UvQueue> queue_ = nullptr;
40 };
41 
42 } // namespace RelationalStoreJsKit
43 } // namespace OHOS
44 #endif //RDB_JSKIT_NAPI_RDB_LOG_OBSERVER_H
45