home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / main.bin / log.h < prev    next >
C/C++ Source or Header  |  1997-11-24  |  2KB  |  80 lines

  1. /*
  2.  * @(#)log.h    1.9 97/01/06
  3.  * 
  4.  * Copyright (c) 1995, 1996 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  * CopyrightVersion 1.1_beta
  20.  * 
  21.  */
  22.  
  23. /*
  24.  * Logging utilities for debugging.
  25.  */
  26.  
  27. #ifndef _LOG_H_
  28. #define _LOG_H_
  29.  
  30. #ifdef LOGGING
  31.  
  32. #include <stdio.h>
  33.  
  34. /*
  35.  * NOTE: I [Tim] changed command-line parsing of the -l flag to allow
  36.  * -l0 to be passed in.  PERMANENT LOG STATEMENTS SHOULD NOT USE LEVEL 0!
  37.  * It is intended to be used temporarily to limit logging output to
  38.  * specific messages during debugging.  Otherwise even level 1 logging
  39.  * buries you in output.
  40.  */
  41.  
  42. int jio_fprintf(FILE *, const char *fmt, ...);
  43. extern int logging_level;
  44.  
  45. #define Log(level, message) {            \
  46.     if (level <= logging_level)            \
  47.     jio_fprintf(stderr, message);        \
  48. }
  49.  
  50. #define Log1(level, message, x1) {        \
  51.     if (level <= logging_level)            \
  52.     jio_fprintf(stderr, message, (x1));        \
  53. }
  54.  
  55. #define Log2(level, message, x1, x2) {        \
  56.     if (level <= logging_level)            \
  57.     jio_fprintf(stderr, message, (x1), (x2));    \
  58. }
  59.  
  60. #define Log3(level, message, x1, x2, x3) {        \
  61.     if (level <= logging_level)                \
  62.     jio_fprintf(stderr, message, (x1), (x2), (x3));    \
  63. }
  64.  
  65. #define Log4(level, message, x1, x2, x3, x4) {            \
  66.     if (level <= logging_level)                    \
  67.     jio_fprintf(stderr, message, (x1), (x2), (x3), (x4));    \
  68. }
  69.  
  70. #else
  71.  
  72. #define Log(level, message)
  73. #define Log1(level, message, x1)
  74. #define Log2(level, message, x1, x2)
  75. #define Log3(level, message, x1, x2, x3)
  76. #define Log4(level, message, x1, x2, x3, x4)
  77.  
  78. #endif /* LOGGING */
  79. #endif /* !_LOG_H_ */
  80.