The vbs tools - vbs_ls, vbs_rm, vbs_fs - for listing, removing and mounting vbs and Mark6 format scattered VLBI recordings on FlexBuff and Mark6 systems
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

78 lines
2.6 KiB

  1. // macros for debugging
  2. // Copyright (C) 2007-2008 Harro Verkouter
  3. //
  4. // This program is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // any later version.
  8. //
  9. // This program is distributed in the hope that it will be useful, but WITHOUT ANY
  10. // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  11. // PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. //
  13. // You should have received a copy of the GNU General Public License
  14. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. //
  16. // Author: Harro Verkouter - verkouter@jive.nl
  17. // Joint Institute for VLBI in Europe
  18. // P.O. Box 2
  19. // 7990 AA Dwingeloo
  20. #ifndef EVLBI5A_EVLBIDEBUG_H
  21. #define EVLBI5A_EVLBIDEBUG_H
  22. #include <iostream>
  23. #include <sstream>
  24. #include <time.h>
  25. #include <sys/time.h>
  26. #include <stdio.h>
  27. #ifdef __GNUC__
  28. #define EVDBG_FUNC "[" << __PRETTY_FUNCTION__ << "] "
  29. #else
  30. #define EVDBG_FUNC ""
  31. #endif
  32. int dbglev_fn( void ); // get current debuglevel
  33. int dbglev_fn( int n ); // set current level to 'n', returns previous level
  34. // functionname printing threshold:
  35. // if dbglev()>fnthres() then the functionnames
  36. // where the DEBUG() was issued from will be printed as well
  37. // [that is: if the __PRETTY_FUNCTION__ is available otherwise
  38. // it has no effect]
  39. int fnthres_fn( void ); // get current threshold value
  40. int fnthres_fn( int n ); // set current threshold value, returns previous level
  41. void do_cerr_lock( void );
  42. void do_cerr_unlock( void );
  43. // Prepare the debugstring in a local variable.
  44. // We do that so the amount of time spent holding the lock
  45. // is minimal.
  46. // this printed the actual level of the message. taken that out
  47. // OsS_ZyP << a << " ";
  48. #define DEBUG(a, b) \
  49. do {\
  50. if( a<=dbglev_fn() ) {\
  51. std::ostringstream OsS_ZyP;\
  52. char t1m3_buff3r[32];\
  53. struct timeval raw_t1m3; \
  54. ::gettimeofday(&raw_t1m3, NULL); \
  55. ::strftime( t1m3_buff3r, sizeof(t1m3_buff3r), "%Y-%m-%d %H:%M:%S", gmtime(&raw_t1m3.tv_sec) ); \
  56. ::sprintf( t1m3_buff3r + 19, ".%02ld: ", (long int)(raw_t1m3.tv_usec / 10000) ); \
  57. OsS_ZyP << t1m3_buff3r;\
  58. if( dbglev_fn()>fnthres_fn() ) \
  59. OsS_ZyP << EVDBG_FUNC; \
  60. OsS_ZyP << b;\
  61. do_cerr_lock();\
  62. std::cerr << OsS_ZyP.str();\
  63. do_cerr_unlock();\
  64. }\
  65. } while( 0 );
  66. #endif