Skip to content

Commit

Permalink
Merge pull request #3810 from lcy-seso/fix_print_layer
Browse files Browse the repository at this point in the history
fix the problem that long message will be truncated.
  • Loading branch information
emailweixu authored Sep 1, 2017
2 parents 2d31ab5 + ba1aa60 commit fc8a1af
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion paddle/gserver/layers/PrintLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,16 @@ class PrintLayer : public Layer {
<< inputLayers_.size() << ") at " << getName();
}
s << format.substr(pos);
LOG(INFO) << s.str();

const std::string delimiter("\n");
std::string content = s.str();
std::string::size_type foundPos = 0;
std::string::size_type prevPos = 0;
while ((foundPos = content.find(delimiter, prevPos)) != std::string::npos) {
LOG(INFO) << content.substr(prevPos, foundPos - prevPos);
prevPos = foundPos + delimiter.size();
}
LOG(INFO) << content.substr(prevPos);
}

void backward(const UpdateCallback& callback) override {}
Expand Down

0 comments on commit fc8a1af

Please sign in to comment.