Commit ee97ed3d authored by Qiwei Ye's avatar Qiwei Ye
Browse files

using advanced logger for lightGBM

parent 2d0e8fc9
......@@ -60,7 +60,7 @@ public:
TcpSocket() {
sockfd_ = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (sockfd_ == INVALID_SOCKET) {
Log::Stderr("socket construct error");
Log::Error("socket construct error");
return;
}
ConfigSocket();
......@@ -69,7 +69,7 @@ public:
explicit TcpSocket(SOCKET socket) {
sockfd_ = socket;
if (sockfd_ == INVALID_SOCKET) {
Log::Stderr("passed socket error");
Log::Error("passed socket error");
return;
}
ConfigSocket();
......@@ -97,11 +97,11 @@ public:
#if defined(_WIN32)
WSADATA wsa_data;
if (WSAStartup(MAKEWORD(2, 2), &wsa_data) == -1) {
Log::Stderr("socket error: start up error");
Log::Error("socket error: start up error");
}
if (LOBYTE(wsa_data.wVersion) != 2 || HIBYTE(wsa_data.wVersion) != 2) {
WSACleanup();
Log::Stderr("socket error: Winsock.dll version error");
Log::Error("socket error: Winsock.dll version error");
}
#else
#endif
......@@ -128,7 +128,7 @@ public:
char buffer[512];
// get hostName
if (gethostname(buffer, sizeof(buffer)) == SOCKET_ERROR) {
Log::Stderr("Error code: %d, when getting local host name.", WSAGetLastError());
Log::Error("Error code: %d, when getting local host name.", WSAGetLastError());
}
// push local ip
PIP_ADAPTER_INFO pAdapterInfo;
......@@ -137,7 +137,7 @@ public:
ULONG ulOutBufLen = sizeof(IP_ADAPTER_INFO);
pAdapterInfo = (IP_ADAPTER_INFO *)MALLOC(sizeof(IP_ADAPTER_INFO));
if (pAdapterInfo == NULL) {
Log::Stderr("Error allocating memory needed to call GetAdaptersinfo\n");
Log::Error("Error allocating memory needed to call GetAdaptersinfo\n");
}
// Make an initial call to GetAdaptersInfo to get
// the necessary size into the ulOutBufLen variable
......@@ -145,7 +145,7 @@ public:
FREE(pAdapterInfo);
pAdapterInfo = (IP_ADAPTER_INFO *)MALLOC(ulOutBufLen);
if (pAdapterInfo == NULL) {
Log::Stderr("Error allocating memory needed to call GetAdaptersinfo\n");
Log::Error("Error allocating memory needed to call GetAdaptersinfo\n");
}
}
if ((dwRetVal = GetAdaptersInfo(pAdapterInfo, &ulOutBufLen)) == NO_ERROR) {
......@@ -218,7 +218,7 @@ public:
inline TcpSocket Accept() {
SOCKET newfd = accept(sockfd_, NULL, NULL);
if (newfd == INVALID_SOCKET) {
Log::Stderr("socket accept error,error code: %d", GetLastError());
Log::Error("socket accept error,error code: %d", GetLastError());
}
return TcpSocket(newfd);
}
......@@ -226,7 +226,7 @@ public:
inline int Send(const char *buf_, int len, int flag = 0) {
int cur_cnt = send(sockfd_, buf_, len, flag);
if (cur_cnt == SOCKET_ERROR) {
Log::Stderr("socket send error, error code: %d", GetLastError());
Log::Error("socket send error, error code: %d", GetLastError());
}
return cur_cnt;
}
......@@ -234,7 +234,7 @@ public:
inline int Recv(char *buf_, int len, int flags = 0) {
int cur_cnt = recv(sockfd_, buf_ , len , flags);
if (cur_cnt == SOCKET_ERROR) {
Log::Stderr("socket recv error, error code: %d", GetLastError());
Log::Error("socket recv error, error code: %d", GetLastError());
}
return cur_cnt;
}
......
......@@ -16,7 +16,7 @@ public:
is_unbalance_ = config.is_unbalance;
sigmoid_ = static_cast<score_t>(config.sigmoid);
if (sigmoid_ <= 0.0) {
Log::Stderr("sigmoid param %f should greater than zero", sigmoid_);
Log::Error("sigmoid param %f should greater than zero", sigmoid_);
}
}
~BinaryLogloss() {}
......@@ -34,10 +34,10 @@ public:
++cnt_negative;
}
}
Log::Stdout("number of postive:%d number of negative:%d", cnt_positive, cnt_negative);
Log::Info("number of postive:%d number of negative:%d", cnt_positive, cnt_negative);
// cannot continue if all sample are same class
if (cnt_positive == 0 || cnt_negative == 0) {
Log::Stderr("input training data only contain one class");
Log::Error("input training data only contain one class");
}
// use -1 for negative class, and 1 for positive class
label_val_[0] = -1;
......
......@@ -31,7 +31,7 @@ public:
optimize_pos_at_ = config.max_position;
sigmoid_table_ = nullptr;
if (sigmoid_ <= 0.0) {
Log::Stderr("sigmoid param %f should greater than zero", sigmoid_);
Log::Error("sigmoid param %f should greater than zero", sigmoid_);
}
}
~LambdarankNDCG() {
......@@ -47,7 +47,7 @@ public:
// get boundries
query_boundaries_ = metadata.query_boundaries();
if (query_boundaries_ == nullptr) {
Log::Stderr("For NDCG metric, should have query information");
Log::Error("For NDCG metric, should have query information");
}
num_queries_ = metadata.num_queries();
// cache inverse max DCG, avoid compution many times
......
......@@ -95,7 +95,7 @@ void SerialTreeLearner::Init(const Dataset* train_data) {
if (has_ordered_bin_) {
is_data_in_leaf_ = new char[num_data_];
}
Log::Stdout("#data:%d #feature:%d\n", num_data_, num_features_);
Log::Info("#data:%d #feature:%d\n", num_data_, num_features_);
}
......@@ -123,7 +123,7 @@ Tree* SerialTreeLearner::Train(const score_t* gradients, const score_t *hessians
const SplitInfo& best_leaf_SplitInfo = best_split_per_leaf_[best_leaf];
// cannot split, quit
if (best_leaf_SplitInfo.gain <= 0.0) {
Log::Stdout("cannot find more split with gain = %f , current #leaves=%d\n",
Log::Info("cannot find more split with gain = %f , current #leaves=%d\n",
best_leaf_SplitInfo.gain, split + 1);
break;
}
......
......@@ -197,6 +197,7 @@
<ClInclude Include="..\src\treelearner\split_info.hpp" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\include\LightGBM\utils\log.cpp" />
<ClCompile Include="..\src\application\application.cpp" />
<ClCompile Include="..\src\boosting\boosting.cpp" />
<ClCompile Include="..\src\boosting\gbdt.cpp" />
......
......@@ -221,5 +221,8 @@
<ClCompile Include="..\src\main.cpp">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="..\include\LightGBM\utils\log.cpp">
<Filter>include\LightGBM\utils</Filter>
</ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment