Advertisement
Guest User

Untitled

a guest
Jul 24th, 2012
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.48 KB | None | 0 0
  1. #define SA_LOG( fmt, ... )\
  2. {\
  3.     FILE* fp = fopen( "salog.log", "a" );\
  4.     struct timeval tv;\
  5.     memset( &tv, 0, sizeof(struct timeval) );\
  6.     gettimeofday( &tv, NULL );\
  7.     char* ct = ctime( &(tv.tv_sec) );\
  8.     size_t ctl = strlen( ct );\
  9.     ct[ (ctl>=6 ? ctl-6 : 0) ] = 0x00;\
  10.     fprintf( fp,\
  11.         "%s.%06ld %s:%d || %s: " fmt "\n",\
  12.         ct+8, tv.tv_usec,\
  13.         ( rindex(__FILE__, '/') ? rindex(__FILE__, '/') : __FILE__ ) ,\
  14.         __LINE__, __PRETTY_FUNCTION__,\
  15.         ##__VA_ARGS__ );\
  16.     fclose( fp );\
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement