From 9ba130f4628d8e52ebd50b810e761a81f69c0c4a Mon Sep 17 00:00:00 2001 From: Björn Steinbrink Date: Thu, 25 Aug 2005 20:03:31 +0000 Subject: Move extern declaration of the floor item list. Lower indentation level. --- src/log.cpp | 55 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 27 deletions(-) (limited to 'src/log.cpp') 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) -- cgit v1.2.3-60-g2f50