/src/WasmEdge/lib/plugin/wasi_logging/module.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | // SPDX-License-Identifier: Apache-2.0 |
2 | | // SPDX-FileCopyrightText: 2019-2024 Second State INC |
3 | | |
4 | | // BUILTIN-PLUGIN: Temporary move the wasi-logging plugin sources here until |
5 | | // the new plugin architecture ready in 0.15.0. |
6 | | |
7 | | #include "plugin/wasi_logging/module.h" |
8 | | #include "plugin/plugin.h" |
9 | | #include "plugin/wasi_logging/func.h" |
10 | | |
11 | | #include <string_view> |
12 | | |
13 | | namespace WasmEdge { |
14 | | namespace Host { |
15 | | |
16 | | namespace { |
17 | | Runtime::Instance::ModuleInstance * |
18 | 0 | create(const Plugin::PluginModule::ModuleDescriptor *) noexcept { |
19 | 0 | return new WasiLoggingModule; |
20 | 0 | } |
21 | | } // namespace |
22 | | |
23 | | using namespace std::literals; |
24 | | |
25 | | const std::string WASILogging::LogEnv::DefFormat = |
26 | | "[%Y-%m-%d %H:%M:%S.%e] [%^%l%$] %v"; |
27 | | std::mutex WASILogging::LogEnv::Mutex; |
28 | | std::unordered_set<uint64_t> WASILogging::LogEnv::RegisteredID; |
29 | | |
30 | | WasiLoggingModule::WasiLoggingModule() |
31 | 0 | : ModuleInstance("wasi:logging/logging"sv) { |
32 | 0 | addHostFunc("log"sv, std::make_unique<WASILogging::Log>(Env)); |
33 | 0 | } |
34 | | |
35 | | Plugin::PluginModule::ModuleDescriptor WasiLoggingModule::ModuleDescriptor[]{ |
36 | | { |
37 | | /* Name */ "wasi:logging/logging", |
38 | | /* Description */ "", |
39 | | /* Create */ create, |
40 | | }, |
41 | | }; |
42 | | |
43 | | Plugin::Plugin::PluginDescriptor WasiLoggingModule::PluginDescriptor{ |
44 | | /* Name */ "wasi_logging", |
45 | | /* Description */ "", |
46 | | /* APIVersion */ Plugin::Plugin::CurrentAPIVersion, |
47 | | /* Version */ {0, 1, 0, 0}, |
48 | | /* ModuleCount */ 1, |
49 | | /* ModuleDescriptions */ ModuleDescriptor, |
50 | | /* ComponentCount */ 0, |
51 | | /* ComponentDescriptions */ nullptr, |
52 | | /* AddOptions */ nullptr, |
53 | | }; |
54 | | |
55 | | } // namespace Host |
56 | | } // namespace WasmEdge |