home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / sybase / starbuck / java.z / log.h < prev    next >
C/C++ Source or Header  |  1996-05-03  |  2KB  |  76 lines

  1. /*
  2.  * @(#)log.h    1.6 95/07/17  
  3.  *
  4.  * Copyright (c) 1994 Sun Microsystems, Inc. All Rights Reserved.
  5.  *
  6.  * Permission to use, copy, modify, and distribute this software
  7.  * and its documentation for NON-COMMERCIAL purposes and without
  8.  * fee is hereby granted provided that this copyright notice
  9.  * appears in all copies. Please refer to the file "copyright.html"
  10.  * for further important copyright and licensing information.
  11.  *
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
  13.  * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
  14.  * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  15.  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
  16.  * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
  17.  * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
  18.  */
  19.  
  20. /*
  21.  * Logging utilities for debugging.
  22.  */
  23.  
  24. #ifndef _LOG_H_
  25. #define _LOG_H_
  26.  
  27. #ifdef LOGGING
  28.  
  29. #include <stdio.h>
  30.  
  31. /*
  32.  * NOTE: I [Tim] changed command-line parsing of the -l flag to allow
  33.  * -l0 to be passed in.  PERMANENT LOG STATEMENTS SHOULD NOT USE LEVEL 0!
  34.  * It is intended to be used temporarily to limit logging output to
  35.  * specific messages during debugging.  Otherwise even level 1 logging
  36.  * buries you in output.
  37.  */
  38.  
  39. extern int logging_level;
  40.  
  41. #define Log(level, message) {            \
  42.     if (level <= logging_level)            \
  43.     fprintf(stderr, message);        \
  44. }
  45.  
  46. #define Log1(level, message, x1) {        \
  47.     if (level <= logging_level)            \
  48.     fprintf(stderr, message, (x1));        \
  49. }
  50.  
  51. #define Log2(level, message, x1, x2) {        \
  52.     if (level <= logging_level)            \
  53.     fprintf(stderr, message, (x1), (x2));    \
  54. }
  55.  
  56. #define Log3(level, message, x1, x2, x3) {        \
  57.     if (level <= logging_level)                \
  58.     fprintf(stderr, message, (x1), (x2), (x3));    \
  59. }
  60.  
  61. #define Log4(level, message, x1, x2, x3, x4) {            \
  62.     if (level <= logging_level)                    \
  63.     fprintf(stderr, message, (x1), (x2), (x3), (x4));    \
  64. }
  65.  
  66. #else
  67.  
  68. #define Log(level, message)
  69. #define Log1(level, message, x1)
  70. #define Log2(level, message, x1, x2)
  71. #define Log3(level, message, x1, x2, x3)
  72. #define Log4(level, message, x1, x2, x3, x4)
  73.  
  74. #endif /* LOGGING */
  75. #endif /* !_LOG_H_ */
  76.