Skip to content

Commit 2433e35

Browse files
authored
fix wasmedge spdlog (#2199)
Signed-off-by: turuslan <[email protected]>
1 parent de64069 commit 2433e35

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

cmake/dependencies.cmake

+2
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ find_package(zstd CONFIG REQUIRED)
9999
if ("${WASM_COMPILER}" STREQUAL "WasmEdge")
100100
hunter_add_package(WasmEdge)
101101
find_package(WasmEdge REQUIRED CONFIG)
102+
hunter_add_package(spdlog)
103+
find_package(spdlog REQUIRED CONFIG)
102104
endif ()
103105

104106
hunter_add_package(rocksdb)

core/parachain/CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ target_link_libraries(kagome_pvf_worker
8787
p2p::p2p_asio_scheduler_backend
8888
)
8989

90+
if("${WASM_COMPILER}" STREQUAL "WasmEdge")
91+
target_link_libraries(kagome_pvf_worker PUBLIC
92+
spdlog::spdlog
93+
)
94+
endif()
95+
9096
if (CMAKE_SYSTEM_NAME STREQUAL Linux)
9197
target_link_libraries(kagome_pvf_worker PRIVATE seccomp)
9298
endif()

core/parachain/pvf/kagome_pvf_worker.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "parachain/pvf/kagome_pvf_worker_injector.hpp"
3939
#include "parachain/pvf/pvf_worker_types.hpp"
4040
#include "scale/scale.hpp"
41+
#include "utils/spdlog_stderr.hpp"
4142

4243
#include "parachain/pvf/kagome_pvf_worker.hpp"
4344
#include "parachain/pvf/secure_mode.hpp"
@@ -367,6 +368,8 @@ namespace kagome::parachain {
367368
}
368369

369370
int pvf_worker_main(int argc, const char **argv, const char **env) {
371+
spdlogStderr();
372+
370373
auto logging_system = std::make_shared<soralog::LoggingSystem>(
371374
std::make_shared<kagome::log::Configurator>(
372375
std::make_shared<libp2p::log::Configurator>()));

core/utils/spdlog_stderr.hpp

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Copyright Quadrivium LLC
3+
* All Rights Reserved
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#pragma once
8+
9+
#if KAGOME_WASM_COMPILER_WASM_EDGE
10+
#include <spdlog/sinks/ansicolor_sink.h>
11+
#include <spdlog/spdlog.h>
12+
13+
// fix wasmedge spdlog, change stdout to stderr
14+
inline void spdlogStderr() {
15+
spdlog::default_logger()->sinks() = {
16+
std::make_shared<spdlog::sinks::ansicolor_stderr_sink_mt>()};
17+
}
18+
#else
19+
inline void spdlogStderr() {}
20+
#endif

0 commit comments

Comments
 (0)