Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

调试日志中打印配置信息 #448

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion src/main/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,36 @@ struct arguments {
int discovery = 0;
int routeCost = 0;
int mtu = 1400;

void dump(const std::string &key, const std::string &value) {
if (!value.empty()) {
spdlog::debug("--{}={}", key, value);
}
}
void dump(const std::string &key, int value) {
if (value) {
spdlog::debug("--{}={}", key, value);
}
}
void dump() {
spdlog::debug("================================");
dump("mode", this->mode);
dump("websocket", this->websocket);
dump("password", this->password);
dump("restart", this->restart);
dump("dhcp", this->dhcp);
dump("sdwan", this->sdwan);
dump("name", this->name);
dump("tun", this->tun);
dump("stun", this->stun);
dump("localhost", this->localhost);
dump("discovery", this->discovery);
dump("route", this->routeCost);
dump("mtu", this->mtu);
dump("workers", this->workers);
dump("port", this->udpPort);
spdlog::debug("================================");
}
};

int disableLogTimestamp() {
Expand All @@ -52,7 +82,6 @@ int disableLogTimestamp() {

int setLogLevelDebug() {
spdlog::set_level(spdlog::level::debug);
spdlog::debug("set log level: debug");
return 0;
}

Expand Down Expand Up @@ -365,6 +394,7 @@ int parseConfig(int argc, char *argv[], arguments &args) {
}
if (args.debug) {
setLogLevelDebug();
args.dump();
}
return 0;
} catch (const std::exception &e) {
Expand Down
1 change: 0 additions & 1 deletion src/tun/linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <memory>
#include <net/if.h>
#include <net/route.h>
#include <queue>
#include <spdlog/spdlog.h>
#include <string>
#include <sys/ioctl.h>
Expand Down