TimeStamp.cpp
Go to the documentation of this file.
1 /*
2  * TimeStamp.cpp
3  *
4  * Copyright 2001, LifeLine Networks BV (www.lifeline.nl). All rights reserved.
5  * Copyright 2001, Bastiaan Bakker. All rights reserved.
6  *
7  * See the COPYING file for the terms of usage and distribution.
8  */
9 
10 #include <log4cpp/TimeStamp.hh>
11 
12 #include <cstring>
13 
14 #ifdef LOG4CPP_HAVE_GETTIMEOFDAY
15 #include <sys/time.h>
16 #else
17 #ifdef LOG4CPP_HAVE_FTIME
18 #include <sys/timeb.h>
19 #else
20 #include <time.h>
21 #endif
22 #endif
23 
24 namespace log4cpp {
25 
27 
29 #ifdef LOG4CPP_HAVE_GETTIMEOFDAY
30  struct timeval tv;
31  ::gettimeofday(&tv, NULL);
32  _seconds = tv.tv_sec;
33  _microSeconds = tv.tv_usec;
34 #else
35 #ifdef LOG4CPP_HAVE_FTIME
36  struct timeb tb;
37  ::ftime(&tb);
38  _seconds = tb.time;
39  _microSeconds = 1000 * tb.millitm;
40 #else
41  _seconds = ::time(NULL);
42  _microSeconds = 0;
43 #endif
44 #endif
45  }
46 
47  TimeStamp::TimeStamp(unsigned int seconds, unsigned int microSeconds) :
48  _seconds(seconds),
49  _microSeconds(microSeconds) {
50  }
51 }
52 
53 
static TimeStamp _startStamp
Definition: TimeStamp.hh:63
#define LOG4CPP_EXPORT
Definition: Export.hh:26


log4cpp
Author(s): Stephen Roderick, Bastiaan Bakker, Cedric Le Goater, Steve Ostlind, Marcel Harkema, Walter Stroebel, Glenn Scott and Tony Cheung
autogenerated on Sun Jun 23 2019 19:14:17