12#ifndef OPENVPN_LOG_LOGPERIOD_H
13#define OPENVPN_LOG_LOGPERIOD_H
90 std::ostringstream
os;
92 const time_t time = time_t(
start_);
93 if (!localtime_r(&time, <))
94 throw log_period_error(
"to_string localtime_r");
95 os << std::setfill(
'0');
96 os << std::setw(4) << (lt.tm_year + 1900) <<
'.' << std::setw(2) << (lt.tm_mon + 1) <<
'.' << std::setw(2) << lt.tm_mday;
98 os <<
'-' << std::setw(2) << lt.tm_hour <<
':' << std::setw(2) << lt.tm_min;
106 else if (
str ==
"hourly")
108 else if (
str ==
"by_minute")
111 throw log_period_error(
"unknown period: " +
str);
126 throw log_period_error(
"undefined period");
133 if (!localtime_r(&time, <))
134 throw log_period_error(
"period_base localtime_r");
150 throw log_period_error(
"unknown period");
152 const time_t
ret = mktime(<);
154 throw log_period_error(
"mktime");
LogPeriod(const Period period, const time_t base)
LogPeriod(const LogPeriod &other, const int index)
static olong period_sec(const Period p)
OPENVPN_EXCEPTION(log_period_error)
std::string to_string() const
static Period period_from_string(const std::string &str)
std::string to_string_verbose() const
static olong period_base(const Period p, const time_t time)
time_t expires_in(const time_t now)
bool is_current(const time_t now) const
os<< "Session Name: "<< tbc-> session_name<< '\n';os<< "Layer: "<< tbc-> layer str()<< '\n'