Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2012-11-18 22:20:56 +0000
committerStijn Buys <ingar@osirion.org>2012-11-18 22:20:56 +0000
commit3dc60689b9327190eeecd42f6920299ef3e7b52c (patch)
treee377684c0fad1d01c9dcab0acfcae8df718e63c9 /src
parent5d959c5ba476eb0b103fe5953cca69939a6d836a (diff)
Corrected dedicated server log timestamp issues.
Diffstat (limited to 'src')
-rw-r--r--src/dedicated/console.cc45
1 files changed, 28 insertions, 17 deletions
diff --git a/src/dedicated/console.cc b/src/dedicated/console.cc
index 5d16848..7986f2e 100644
--- a/src/dedicated/console.cc
+++ b/src/dedicated/console.cc
@@ -122,12 +122,21 @@ void Console::open_log()
console_logfilename.clear();
con_warn << "Could not open logfile " << errfilename << std::endl;
} else {
- logfile.close();
-
// dump console content
for (Queue::iterator it = log().begin(); it != log().end(); it++) {
- print((*it));
+ int year = 0, month = 0, day = 0, hour = 0, min = 0, sec = 0, milliseconds = 0;
+ sys::get_localtime(year, month, day, hour, min, sec, milliseconds);
+
+ logfile << std::setw(4) << std::setfill('0') << year << "-"
+ << std::setw(2) << std::setfill('0') << month << "-"
+ << std::setw(2) << std::setfill('0') << day << " "
+ << std::setw(2) << std::setfill('0') << hour << ":"
+ << std::setw(2) << std::setfill('0') << min << ":"
+ << std::setw(2) << std::setfill('0') << sec << " "
+ << std::setw(2) << " "
+ << aux::text_strip((*it)) << std::endl;
}
+ logfile.close();
}
}
@@ -148,16 +157,18 @@ void Console::print(const std::string & text)
std::ofstream logfile;
logfile.open(console_logfilename.c_str(), std::ios::app);
if (logfile.is_open()) {
- int year = 0, month = 0, day = 0, hour = 0, min = 0, sec = 0, milliseconds = 0;
- sys::get_localtime(year, month, day, hour, min, sec, milliseconds);
- logfile << std::setw(4) << std::setfill('0') << year << "-"
- << std::setw(2) << std::setfill('0') << month << "-"
- << std::setw(2) << std::setfill('0') << day << " "
- << std::setw(2) << std::setfill('0') << hour << ":"
- << std::setw(2) << std::setfill('0') << min << ":"
- << std::setw(2) << std::setfill('0') << sec << " "
- << std::setw(2) << " "
- << aux::text_strip(text) << std::endl;
+ if (!sys::console_timestamps()) {
+ int year = 0, month = 0, day = 0, hour = 0, min = 0, sec = 0, milliseconds = 0;
+ sys::get_localtime(year, month, day, hour, min, sec, milliseconds);
+ logfile << std::setw(4) << std::setfill('0') << year << "-"
+ << std::setw(2) << std::setfill('0') << month << "-"
+ << std::setw(2) << std::setfill('0') << day << " "
+ << std::setw(2) << std::setfill('0') << hour << ":"
+ << std::setw(2) << std::setfill('0') << min << ":"
+ << std::setw(2) << std::setfill('0') << sec << " "
+ << std::setw(2) << " ";
+ }
+ logfile << aux::text_strip(text) << std::endl;
logfile.close();
}
}
@@ -260,9 +271,9 @@ void Console::draw_status()
status << std::setw(4) << std::setfill('0') << year << "-"
<< std::setw(2) << std::setfill('0') << month << "-"
<< std::setw(2) << std::setfill('0') << day << " "
- << std::setw(2) << hour << ":"
- << std::setw(2) << min << ":"
- << std::setw(2) << sec << " "
+ << std::setw(2) << std::setfill(' ') << hour << ":"
+ << std::setw(2) << std::setfill('0') << min << ":"
+ << std::setw(2) << std::setfill('0') << sec << " "
<< std::setw(2) << " ";
// uptime
@@ -283,7 +294,7 @@ void Console::draw_status()
if (uptime_days > 0) {
status << uptime_days << " " << aux::plural("day", uptime_days) << " ";
}
- status << std::setfill('0') << std::setw(2) << uptime_hours << ":"
+ status << std::setfill(' ') << std::setw(2) << uptime_hours << ":"
<< std::setfill('0') << std::setw(2) << uptime_minutes << ":"
<< std::setfill('0') << std::setw(2) << uptime_seconds;