TimeStamp.cpp
Go to the documentation of this file.
00001 /*
00002  * TimeStamp.cpp
00003  *
00004  * Copyright 2001, LifeLine Networks BV (www.lifeline.nl). All rights reserved.
00005  * Copyright 2001, Bastiaan Bakker. All rights reserved.
00006  *
00007  * See the COPYING file for the terms of usage and distribution.
00008  */
00009 
00010 #include <log4cpp/TimeStamp.hh>
00011 
00012 #include <cstring>
00013 
00014 #ifdef LOG4CPP_HAVE_GETTIMEOFDAY
00015 #include <sys/time.h>
00016 #else
00017 #ifdef LOG4CPP_HAVE_FTIME
00018 #include <sys/timeb.h>
00019 #else
00020 #include <time.h>
00021 #endif
00022 #endif
00023 
00024 namespace log4cpp {
00025 
00026     LOG4CPP_EXPORT TimeStamp TimeStamp::_startStamp;
00027 
00028     TimeStamp::TimeStamp() {
00029 #ifdef LOG4CPP_HAVE_GETTIMEOFDAY
00030         struct timeval tv;
00031         ::gettimeofday(&tv, NULL);
00032         _seconds = tv.tv_sec;
00033         _microSeconds = tv.tv_usec;
00034 #else
00035 #ifdef LOG4CPP_HAVE_FTIME
00036         struct timeb tb;
00037         ::ftime(&tb);
00038         _seconds = tb.time;
00039         _microSeconds = 1000 * tb.millitm;
00040 #else
00041         _seconds = ::time(NULL);
00042         _microSeconds = 0;
00043 #endif
00044 #endif
00045     }
00046 
00047     TimeStamp::TimeStamp(unsigned int seconds, unsigned int microSeconds) :
00048         _seconds(seconds),
00049         _microSeconds(microSeconds) {
00050     }
00051 }
00052 
00053 


log4cpp
Author(s): Stephen Roderick, Bastiaan Bakker, Cedric Le Goater, Steve Ostlind, Marcel Harkema, Walter Stroebel, Glenn Scott and Tony Cheung.
autogenerated on Thu Jan 2 2014 11:35:02