/src/spicy/hilti/runtime/src/configuration.cc
Line | Count | Source |
1 | | // Copyright (c) 2020-now by the Zeek Project. See LICENSE for details. |
2 | | |
3 | | #include <cstdlib> |
4 | | #include <utility> |
5 | | |
6 | | #include <hilti/rt/autogen/config.h> |
7 | | #include <hilti/rt/configuration.h> |
8 | | #include <hilti/rt/global-state.h> |
9 | | #include <hilti/rt/init.h> |
10 | | #include <hilti/rt/logging.h> |
11 | | |
12 | | using namespace hilti::rt; |
13 | | using namespace hilti::rt::detail; |
14 | | |
15 | | std::unique_ptr<hilti::rt::Configuration> configuration::detail::__configuration; |
16 | | |
17 | 5 | Configuration::Configuration() { |
18 | 5 | auto* x = ::getenv("HILTI_DEBUG"); |
19 | 5 | debug_streams = (x ? x : ""); |
20 | 5 | cout = std::cout; |
21 | 5 | } |
22 | | |
23 | 0 | void configuration::set(Configuration cfg) { |
24 | 0 | if ( isInitialized() ) |
25 | 0 | hilti::rt::fatalError("attempt to change configuration after library has already been initialized"); |
26 | |
|
27 | | #ifndef NDEBUG |
28 | | if ( cfg.show_backtraces ) |
29 | | hilti::rt::warning("printing of exception backtraces enabled, but not supported in release builds"); |
30 | | #endif |
31 | |
|
32 | 0 | *detail::__configuration = std::move(cfg); |
33 | 0 | } |