Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vsnet_debug.cpp
Go to the documentation of this file.
1 #include "vsnet_debug.h"
2 
3 #include <time.h>
4 #include <cstring>
5 #if !defined (_WIN32)
6 #include <sys/time.h>
7 #else
8 #include <winsock.h>
9 #endif
10 
11 using std::ostream;
12 using std::clog;
13 
15 
17 ostream& operator<<( ostream &ostr, const TimeTriggerStruct &c )
18 {
19 #ifndef _WIN32
20  struct timeval tv;
21  gettimeofday( &tv, NULL );
22  ostr<<tv.tv_sec<<":"<<tv.tv_usec;
23 #endif
24  return ostr;
25 }
26 
27 ostream& vsnetDbgOut( const char *file, int line )
28 {
29  const char *printme = file;
30  int len = strlen( file );
31  if (len > 30) printme = &file[len-30];
32 #ifdef VSNET_DEBUG
33  clog<<PTHREAD_SELF_OR_NONE<<" "
34  <<time_trigger
35  <<" "<<printme<<":"<<line<<" ";
36 #else /* !VSNET_DEBUG */
37  clog<<printme<<":"<<line<<" ";
38 #endif /* VSNET_DEBUG */
39  return clog;
40 }
41