Skip to content

Commit

Permalink
fix wasmedge spdlog (#2199)
Browse files Browse the repository at this point in the history
Signed-off-by: turuslan <[email protected]>
  • Loading branch information
turuslan authored Aug 30, 2024
1 parent de64069 commit 2433e35
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmake/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ find_package(zstd CONFIG REQUIRED)
if ("${WASM_COMPILER}" STREQUAL "WasmEdge")
hunter_add_package(WasmEdge)
find_package(WasmEdge REQUIRED CONFIG)
hunter_add_package(spdlog)
find_package(spdlog REQUIRED CONFIG)
endif ()

hunter_add_package(rocksdb)
Expand Down
6 changes: 6 additions & 0 deletions core/parachain/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ target_link_libraries(kagome_pvf_worker
p2p::p2p_asio_scheduler_backend
)

if("${WASM_COMPILER}" STREQUAL "WasmEdge")
target_link_libraries(kagome_pvf_worker PUBLIC
spdlog::spdlog
)
endif()

if (CMAKE_SYSTEM_NAME STREQUAL Linux)
target_link_libraries(kagome_pvf_worker PRIVATE seccomp)
endif()
3 changes: 3 additions & 0 deletions core/parachain/pvf/kagome_pvf_worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "parachain/pvf/kagome_pvf_worker_injector.hpp"
#include "parachain/pvf/pvf_worker_types.hpp"
#include "scale/scale.hpp"
#include "utils/spdlog_stderr.hpp"

#include "parachain/pvf/kagome_pvf_worker.hpp"
#include "parachain/pvf/secure_mode.hpp"
Expand Down Expand Up @@ -367,6 +368,8 @@ namespace kagome::parachain {
}

int pvf_worker_main(int argc, const char **argv, const char **env) {
spdlogStderr();

auto logging_system = std::make_shared<soralog::LoggingSystem>(
std::make_shared<kagome::log::Configurator>(
std::make_shared<libp2p::log::Configurator>()));
Expand Down
20 changes: 20 additions & 0 deletions core/utils/spdlog_stderr.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Copyright Quadrivium LLC
* All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*/

#pragma once

#if KAGOME_WASM_COMPILER_WASM_EDGE
#include <spdlog/sinks/ansicolor_sink.h>
#include <spdlog/spdlog.h>

// fix wasmedge spdlog, change stdout to stderr
inline void spdlogStderr() {
spdlog::default_logger()->sinks() = {
std::make_shared<spdlog::sinks::ansicolor_stderr_sink_mt>()};
}
#else
inline void spdlogStderr() {}
#endif

0 comments on commit 2433e35

Please sign in to comment.