• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 
16 #ifndef NWEB_CONSOLE_LOG_H
17 #define NWEB_CONSOLE_LOG_H
18 
19 #include <memory>
20 #include <string>
21 
22 #include "nweb_export.h"
23 
24 namespace OHOS::NWeb {
25 class OHOS_NWEB_EXPORT NWebConsoleLog {
26 public:
27     enum NWebConsoleLogLevel {
28         DEBUG = 1,
29         INFO,
30         WARNING,
31         ERROR,
32         UNKNOWN
33     };
34 
NWebConsoleLog(int line_number,std::string message,NWebConsoleLogLevel log_level,std::string sourceId)35     NWebConsoleLog(int line_number,
36                    std::string message,
37                    NWebConsoleLogLevel log_level,
38                    std::string sourceId)
39         : line_number_(line_number),
40           log_(message),
41           log_level_(log_level),
42           sourceId_(sourceId) {}
43 
44     ~NWebConsoleLog() = default;
45 
46     /**
47      * @brief Get console log line number
48      *
49      * @retval line number
50      */
LineNumer()51     int LineNumer() const {
52         return line_number_;
53     }
54 
55     /**
56      * @brief Get console log message
57      *
58      * @retval message
59      */
Log()60     const std::string& Log() const {
61         return log_;
62     }
63 
64     /**
65      * @brief Get console log message level
66      *
67      * @retval message level
68      */
LogLevel()69     NWebConsoleLogLevel LogLevel() const {
70         return log_level_;
71     }
72 
73     /**
74      * @brief Get console log source id
75      *
76      * @retval source id
77      */
SourceId()78     const std::string& SourceId() const {
79         return sourceId_;
80     }
81 
82 private:
83     int line_number_;
84     std::string log_;
85     NWebConsoleLogLevel log_level_;
86     std::string sourceId_;
87 };
88 }
89 
90 #endif // NWEB_CONSOLE_LOG_H