mirror of https://github.com/aria2/aria2
2008-09-23 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Log microseconds. * src/SimpleLogger.cc (SimpleLogger::writeLog)pull/1/head
parent
2c6d2cd562
commit
2522175ff1
|
@ -1,3 +1,8 @@
|
||||||
|
2008-09-23 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
|
Log microseconds.
|
||||||
|
* src/SimpleLogger.cc (SimpleLogger::writeLog)
|
||||||
|
|
||||||
2008-09-22 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
2008-09-22 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
Replaced HelpItem.cc with OptionHandler.cc.
|
Replaced HelpItem.cc with OptionHandler.cc.
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -142,11 +143,16 @@ void SimpleLogger::writeLog(std::ostream& o, Logger::LEVEL level,
|
||||||
default:
|
default:
|
||||||
levelStr = INFO;
|
levelStr = INFO;
|
||||||
}
|
}
|
||||||
time_t now = time(NULL);
|
struct timeval tv;
|
||||||
char datestr[20];
|
gettimeofday(&tv, 0);
|
||||||
|
char datestr[27]; // 'YYYY-MM-DD hh:mm:ss.uuuuuu'+'\0' = 27 bytes
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
localtime_r(&now, &tm);
|
localtime_r(&tv.tv_sec, &tm);
|
||||||
strftime(datestr, sizeof(datestr), "%Y-%m-%d %H:%M:%S", &tm);
|
size_t dateLength =
|
||||||
|
strftime(datestr, sizeof(datestr), "%Y-%m-%d %H:%M:%S", &tm);
|
||||||
|
assert(dateLength <= (size_t)20);
|
||||||
|
snprintf(datestr+dateLength, sizeof(datestr)-dateLength,
|
||||||
|
".%06ld", tv.tv_usec);
|
||||||
|
|
||||||
// TODO a quick hack not to print header in console
|
// TODO a quick hack not to print header in console
|
||||||
if(printHeader) {
|
if(printHeader) {
|
||||||
|
|
Loading…
Reference in New Issue