make 'loading' diag messages conditional

pull/4238/head
Miro Stauder 3 years ago
parent d2eb34e109
commit 08b15e7239

@ -44,6 +44,8 @@ libtap.a: tap.cpp tap.h command_line.cpp command_line.h utils.cpp utils.h cpp-do
cpp-dotenv/cpp-dotenv/libcpp_dotenv.a:
cd cpp-dotenv && rm -rf cpp-dotenv-*/ || true
cd cpp-dotenv && tar -zxf cpp-dotenv-*.tar.gz
cd cpp-dotenv/cpp-dotenv && patch src/dotenv.cpp < ../dotenv.cpp.patch
cd cpp-dotenv/cpp-dotenv && patch include/dotenv.h < ../dotenv.h.patch
cd cpp-dotenv/cpp-dotenv && cmake . -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Debug
cd cpp-dotenv/cpp-dotenv && CC=${CC} CXX=${CXX} ${MAKE}
cpp-dotenv: cpp-dotenv/cpp-dotenv/libcpp_dotenv.a

@ -15,7 +15,7 @@
using nlohmann::json;
using dotenv::env;
//using namespace dotenv;
CommandLine::CommandLine() {}
@ -112,56 +112,64 @@ int CommandLine::getEnv() {
std::string dir_path = exe_path.substr(0, exe_path.find_last_of('/'));
std::string dir_name = dir_path.substr(dir_path.find_last_of('/') + 1);
diag("loading: %s", (dir_path + "/.env").c_str());
env.load_dotenv((dir_path + "/.env").c_str(), true);
bool loaded1 = env.loaded;
diag("loading: %s", (dir_path + "/" + dir_name + ".env").c_str());
env.load_dotenv((dir_path + "/" + dir_name + ".env").c_str(), true);
bool loaded2 = env.loaded;
diag("loading: %s", (exe_path + ".env").c_str());
env.load_dotenv((exe_path + ".env").c_str(), true);
bool loaded3 = env.loaded;
bool quiet = (bool) getenv("TAP_QUIET_ENVLOAD");
if (loaded1 && ! quiet)
diag("loaded: %s", (dir_path + "/.env").c_str());
if (loaded2 && ! quiet)
diag("loaded: %s", (dir_path + "/" + dir_name + ".env").c_str());
if (loaded3 && ! quiet)
diag("loaded: %s", (exe_path + ".env").c_str());
}
value=getenv("TAP_HOST");
value = getenv("TAP_HOST");
if (value)
replace_str_field(&this->host, value);
value=getenv("TAP_USERNAME");
value = getenv("TAP_USERNAME");
if (value)
replace_str_field(&this->username, value);
value=getenv("TAP_PASSWORD");
value = getenv("TAP_PASSWORD");
if (value)
replace_str_field(&this->password, value);
value=getenv("TAP_ADMINUSERNAME");
value = getenv("TAP_ADMINUSERNAME");
if (value)
replace_str_field(&this->admin_username, value);
value=getenv("TAP_ADMINPASSWORD");
value = getenv("TAP_ADMINPASSWORD");
if (value)
replace_str_field(&this->admin_password, value);
int env_port = 0;
value=getenv("TAP_PORT");
value = getenv("TAP_PORT");
if (value) {
env_port = strtol(value, NULL, 10);
if (env_port>0 && env_port<65536)
port = env_port;
}
value=getenv("TAP_ADMINPORT");
value = getenv("TAP_ADMINPORT");
if (value) {
env_port = strtol(value, NULL, 10);
if (env_port>0 && env_port<65536)
admin_port = env_port;
}
value=getenv("TAP_WORKDIR");
value = getenv("TAP_WORKDIR");
if (value)
replace_str_field(&this->workdir, value);
value=getenv("TAP_CLIENT_FLAGS");
value = getenv("TAP_CLIENT_FLAGS");
if (value) {
char* end = NULL;
uint64_t env_c_flags = strtoul(value, &end, 10);

@ -0,0 +1,18 @@
--- cpp-dotenv.old/src/dotenv.cpp 2023-06-12 10:09:44.621343972 +0000
+++ cpp-dotenv.new/src/dotenv.cpp 2020-08-09 16:19:56.000000000 +0000
@@ -13,6 +13,7 @@
dotenv::dotenv& dotenv::dotenv::load_dotenv(const string& dotenv_path, const bool overwrite, const bool interpolate)
{
+ loaded = false;
ifstream env_file;
env_file.open(dotenv_path);
@@ -21,6 +22,7 @@
Parser parser;
parser.parse(env_file, overwrite, interpolate);
env_file.close();
+ loaded = true;
}
return *this;

@ -0,0 +1,10 @@
--- cpp-dotenv.old/include/dotenv.h 2023-06-12 10:11:58.748360147 +0000
+++ cpp-dotenv.new/include/dotenv.h 2020-08-09 16:19:56.000000000 +0000
@@ -28,6 +28,7 @@
void operator=(const dotenv&) = delete;
static dotenv& instance();
+ bool loaded = false;
private:
Loading…
Cancel
Save