Created
July 13, 2021 21:21
-
-
Save igor-egorov/2ec967122278f2acc46299a4afc52aed to your computer and use it in GitHub Desktop.
Tuned log settings for Kagome connection issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Template for a custom hunter configuration | |
# Useful when there is a need for a non-default version or arguments of a dependency, | |
# or when a project not registered in soramistu-hunter should be added. | |
# | |
# hunter_config( | |
# package-name | |
# VERSION 0.0.0-package-version | |
# CMAKE_ARGS "CMAKE_VARIABLE=value" | |
# ) | |
# | |
# hunter_config( | |
# package-name | |
# URL https://repo/archive.zip | |
# SHA1 1234567890abcdef1234567890abcdef12345678 | |
# CMAKE_ARGS "CMAKE_VARIABLE=value" | |
# ) | |
hunter_config(libp2p | |
URL https://github.com/libp2p/cpp-libp2p/archive/c56fb58cf282b3cd13400a1230cd4cb741e339ec.tar.gz | |
SHA1 b2b9e0a8d85494adaa0b59f3c7de1692bbc3fb05 | |
CMAKE_ARGS TESTING=OFF EXAMPLES=OFF EXPOSE_MOCKS=ON | |
KEEP_PACKAGE_SOURCES | |
) | |
hunter_config(prometheus-cpp | |
URL "https://github.com/jupp0r/prometheus-cpp/releases/download/v0.12.3/prometheus-cpp-with-submodules.tar.gz" | |
SHA1 0e337607d4ce55cdc80c37b60dcfe4dbbf7812cf | |
CMAKE_ARGS ENABLE_TESTING=OFF USE_THIRDPARTY_LIBRARIES=OFF OVERRIDE_CXX_STANDARD_FLAGS=OFF ENABLE_PULL=OFF ENABLE_PUSH=OFF ENABLE_COMPRESSION=OFF | |
) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright Soramitsu Co., Ltd. All Rights Reserved. | |
* SPDX-License-Identifier: Apache-2.0 | |
*/ | |
#include "log/configurator.hpp" | |
namespace kagome::log { | |
namespace { | |
std::string embedded_config(R"( | |
# ---------------- | |
sinks: | |
- name: console | |
type: console | |
thread: none | |
color: false | |
latency: 0 | |
groups: | |
- name: main | |
sink: console | |
level: error | |
is_fallback: true | |
children: | |
- name: libp2p | |
level: error | |
- name: kagome | |
children: | |
- name: injector | |
- name: application | |
- name: rpc | |
children: | |
- name: rpc_transport | |
- name: api | |
children: | |
- name: author_api | |
- name: authorship | |
- name: blockchain | |
- name: authority | |
- name: crypto | |
children: | |
- name: bip39 | |
- name: crypto_store | |
- name: ed25519 | |
- name: consensus | |
children: | |
- name: babe | |
children: | |
- name: babe_lottery | |
- name: babe_synchronizer | |
- name: block_executor | |
- name: block_validator | |
- name: grandpa | |
children: | |
- name: voting_round | |
- name: runtime | |
level: error | |
children: | |
- name: wasm | |
- name: extensions | |
- name: binaryen | |
- name: metrics | |
- name: network | |
children: | |
- name: protocols | |
- name: changes_trie | |
level: error | |
- name: storage | |
- name: pubsub | |
- name: others | |
children: | |
- name: testing | |
- name: error | |
# ---------------- | |
)"); | |
} | |
Configurator::Configurator(std::shared_ptr<PrevConfigurator> previous) | |
: ConfiguratorFromYAML(std::move(previous), embedded_config) {} | |
Configurator::Configurator(std::shared_ptr<PrevConfigurator> previous, | |
std::string config) | |
: ConfiguratorFromYAML(std::move(previous), std::move(config)) {} | |
Configurator::Configurator(std::shared_ptr<PrevConfigurator> previous, | |
boost::filesystem::path path) | |
: ConfiguratorFromYAML(std::move(previous), | |
std::filesystem::path(path.string())) {} | |
} // namespace kagome::log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright Soramitsu Co., Ltd. All Rights Reserved. | |
* SPDX-License-Identifier: Apache-2.0 | |
*/ | |
#include <iostream> | |
#include <boost/program_options.hpp> | |
#include <libp2p/log/configurator.hpp> | |
#include "application/impl/app_configuration_impl.hpp" | |
#include "application/impl/kagome_application_impl.hpp" | |
#include "log/configurator.hpp" | |
#include "log/logger.hpp" | |
#include "outcome/outcome.hpp" | |
using namespace kagome; | |
using application::AppConfiguration; | |
using application::AppConfigurationImpl; | |
int main(int argc, char **argv) { | |
{ | |
auto logging_system = std::make_shared<soralog::LoggingSystem>( | |
std::make_shared<kagome::log::Configurator>( | |
std::make_shared<libp2p::log::Configurator>())); | |
auto r = logging_system->configure(); | |
if (not r.message.empty()) { | |
(r.has_error ? std::cerr : std::cout) << r.message << std::endl; | |
} | |
if (r.has_error) { | |
exit(EXIT_FAILURE); | |
} | |
kagome::log::setLoggingSystem(logging_system); | |
} | |
auto logger = kagome::log::createLogger("AppConfiguration", "main"); | |
AppConfigurationImpl configuration{logger}; | |
if (configuration.initialize_from_args(argc, argv)) { | |
kagome::log::setLevelOfGroup(kagome::log::defaultGroupName, | |
configuration.verbosity()); | |
auto app = | |
std::make_shared<application::KagomeApplicationImpl>(configuration); | |
kagome::log::setLevelOfLogger("StreamEngine", configuration.verbosity()); | |
app->run(); | |
} | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment