if (CreateLaunchpadDirectories() != 0) THROW(-EIO);
- stream_.open(path_, std::ios::out | std::ios::app);
+ stream_.open(path_, std::ios::out | std::ios::ate);
if (!stream_.is_open()) {
_E("Failed to open path(%s)", path_.c_str());
THROW(-EIO);
struct tm tm;
localtime_r(&t, &tm);
+ static char border = ' ';
const int threshold = 1000000; // 1MB
- if (stream_.tellp() >= threshold) stream_.seekp(0);
+ if (stream_.tellp() >= threshold) {
+ stream_.seekp(0);
+ border = border == ' ' ? '+' : ' ';
+ index_ = 0;
+ }
char buf[256];
int len = snprintf(buf, sizeof(buf),
- "[%6d] %04d-%02d-%02d %02d:%02d:%02d %-16s %-100s\n",
- index_, tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
- tm.tm_hour, tm.tm_min, tm.tm_sec, tag, format_buf);
+ "[%c%5d] %04d-%02d-%02d %02d:%02d:%02d %-16s %-100s\n",
+ border, index_++, tm.tm_year + 1900, tm.tm_mon + 1,
+ tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec,
+ tag, format_buf);
stream_.write(buf, len);
if (!stream_.good()) _E("write() is failed");
stream_.flush();
- index_ = (index_ + 1) % 2500;
}
} // namespace launchpad