summaryrefslogtreecommitdiff
path: root/src/log.cpp
diff options
context:
space:
mode:
authorBjörn Steinbrink <B.Steinbrink@gmx.de>2005-08-25 20:03:31 +0000
committerBjörn Steinbrink <B.Steinbrink@gmx.de>2005-08-25 20:03:31 +0000
commit9ba130f4628d8e52ebd50b810e761a81f69c0c4a (patch)
tree7493736309632e753f4f3aba1d001f14f9ad765f /src/log.cpp
parent7cd9c0d02d148cdbacbca6624d8749a344ddbfe0 (diff)
downloadMana-9ba130f4628d8e52ebd50b810e761a81f69c0c4a.tar.gz
Mana-9ba130f4628d8e52ebd50b810e761a81f69c0c4a.tar.bz2
Mana-9ba130f4628d8e52ebd50b810e761a81f69c0c4a.tar.xz
Mana-9ba130f4628d8e52ebd50b810e761a81f69c0c4a.zip
Move extern declaration of the floor item list. Lower indentation level.
Diffstat (limited to 'src/log.cpp')
-rw-r--r--src/log.cpp55
1 files changed, 28 insertions, 27 deletions
diff --git a/src/log.cpp b/src/log.cpp
index 3222c856..f24461cb 100644
--- a/src/log.cpp
+++ b/src/log.cpp
@@ -50,38 +50,39 @@ void Logger::setLogFile(const std::string &logFilename)
void Logger::log(const char *log_text, ...)
{
- if (logFile.is_open())
- {
- char* buf = new char[1024];
- va_list ap;
- time_t t;
+ if (!logFile.is_open()) {
+ return;
+ }
- // Use a temporary buffer to fill in the variables
- va_start(ap, log_text);
- vsprintf(buf, log_text, ap);
- va_end(ap);
+ char* buf = new char[1024];
+ va_list ap;
+ time_t t;
- // Get the current system time
- time(&t);
+ // Use a temporary buffer to fill in the variables
+ va_start(ap, log_text);
+ vsprintf(buf, log_text, ap);
+ va_end(ap);
- // Print the log entry
- std::stringstream timeStr;
- timeStr << "[";
- timeStr << ((((t / 60) / 60) % 24 < 10) ? "0" : "");
- timeStr << (int)(((t / 60) / 60) % 24);
- timeStr << ":";
- timeStr << (((t / 60) % 60 < 10) ? "0" : "");
- timeStr << (int)((t / 60) % 60);
- timeStr << ":";
- timeStr << ((t % 60 < 10) ? "0" : "");
- timeStr << (int)(t % 60);
- timeStr << "] ";
+ // Get the current system time
+ time(&t);
- logFile << timeStr.str() << buf << std::endl;
+ // Print the log entry
+ std::stringstream timeStr;
+ timeStr << "[";
+ timeStr << ((((t / 60) / 60) % 24 < 10) ? "0" : "");
+ timeStr << (int)(((t / 60) / 60) % 24);
+ timeStr << ":";
+ timeStr << (((t / 60) % 60 < 10) ? "0" : "");
+ timeStr << (int)((t / 60) % 60);
+ timeStr << ":";
+ timeStr << ((t % 60 < 10) ? "0" : "");
+ timeStr << (int)(t % 60);
+ timeStr << "] ";
- // Delete temporary buffer
- delete[] buf;
- }
+ logFile << timeStr.str() << buf << std::endl;
+
+ // Delete temporary buffer
+ delete[] buf;
}
void Logger::error(const std::string &error_text)