1 /* 2 * Copyright (c) 2020 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 OHOS_ACELITE_CONSOLE_MODULE_H 16 #define OHOS_ACELITE_CONSOLE_MODULE_H 17 18 #include "non_copyable.h" 19 #include "presets/preset_module.h" 20 21 namespace OHOS { 22 namespace ACELite { 23 static constexpr char console[] = "console"; 24 class ConsoleModule final : public PresetModule { 25 public: 26 ACE_DISALLOW_COPY_AND_MOVE(ConsoleModule); 27 /** 28 * @fn ConsoleModule::ConsoleModule() 29 * 30 * @brief Constructor. 31 */ ConsoleModule()32 ConsoleModule() : PresetModule(console) {} 33 34 /** 35 * @fn ConsoleModule::~ConsoleModule() 36 * 37 * @brief Constructor. 38 */ 39 ~ConsoleModule() = default; 40 41 void Init() override; 42 Load()43 static void Load() 44 { 45 ConsoleModule consoleModule; 46 consoleModule.Init(); 47 } 48 49 private: 50 /** 51 * @fn ConsoleModule::LogDebug() 52 * 53 * @brief Outputs a message to the console with the log level "debug". 54 * @param func function object 55 * @param context the context of function execution 56 * @param args the list of arguments 57 * @param length the length of arguments list 58 */ 59 static jerry_value_t LogDebug(const jerry_value_t func, 60 const jerry_value_t context, 61 const jerry_value_t* args, 62 const jerry_length_t length); 63 64 /** 65 * @fn ConsoleModule::LogInfo() 66 * 67 * @brief Outputs a message to the console with the log level "info". 68 * @param func function object 69 * @param context the context of function execution 70 * @param args the list of arguments 71 * @param length the length of arguments list 72 */ 73 static jerry_value_t LogInfo(const jerry_value_t func, 74 const jerry_value_t context, 75 const jerry_value_t* args, 76 const jerry_length_t length); 77 78 /** 79 * @fn ConsoleModule::LogWarn() 80 * 81 * @brief Outputs a message to the console with the log level "warn". 82 * @param func function object 83 * @param context the context of function execution 84 * @param args the list of arguments 85 * @param length the length of arguments list 86 */ 87 static jerry_value_t LogWarn(const jerry_value_t func, 88 const jerry_value_t context, 89 const jerry_value_t* args, 90 const jerry_length_t length); 91 92 /** 93 * @fn ConsoleModule::Log() 94 * 95 * @brief Outputs a message to the console with the log level "log". 96 * @param func function object 97 * @param context the context of function execution 98 * @param args the list of arguments 99 * @param length the length of arguments list 100 */ 101 static jerry_value_t Log(const jerry_value_t func, 102 const jerry_value_t context, 103 const jerry_value_t* args, 104 const jerry_length_t length); 105 106 /** 107 * @fn ConsoleModule::LogError() 108 * 109 * @brief Outputs a message to the console with the log level "error". 110 * @param func function object 111 * @param context the context of function execution 112 * @param args the list of arguments 113 * @param length the length of arguments list 114 */ 115 static jerry_value_t LogError(const jerry_value_t func, 116 const jerry_value_t context, 117 const jerry_value_t* args, 118 const jerry_length_t length); 119 }; 120 } // namespace ACELite 121 } // namespace OHOS 122 123 #endif // OHOS_ACELITE_CONSOLE_MODULE_H 124