home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / MiscKit1.7.1 / MiscKit / Examples / AutoDoc / lib / perl5 / Autodoc / LogDebug.pm < prev    next >
Encoding:
Perl POD Document  |  1995-11-02  |  4.4 KB  |  157 lines

  1. package Autodoc::LogDebug;
  2.  
  3. ###############################################################################
  4. ###############################################################################
  5. ##
  6. ##    Written by Adam Swift (c) 1995 by Friday Software and Consulting
  7. ##                           All rights reserved.
  8. ##
  9. ##      This notice may not be removed from this source code.
  10. ##
  11. ##    This program is included in the MiscKit by permission from the author
  12. ##    and its use is governed by the MiscKit license, found in the file
  13. ##    "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
  14. ##    for a list of all applicable permissions and restrictions.
  15. ##
  16. ##    Because AutoDoc is licensed free of charge, there is no warranty 
  17. ##    for the program.  Copyright holder, Friday Software and Consulting, 
  18. ##    is providing this program "as is" and this program is distributed in 
  19. ##    the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
  20. ##    even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
  21. ##    PARTICULAR PURPOSE.
  22. ##
  23. ###############################################################################
  24. ###############################################################################
  25.  
  26. require 5.000;
  27.  
  28. ##########################
  29. # load required packages #
  30. ##########################
  31. use Exporter;
  32.  
  33. @ISA      = qw(Exporter);
  34. @EXPORT   = qw(dblog 
  35.            dblog_debuglevel
  36.            set_dblog_debuglevel);
  37.  
  38. $module_version = '$Revision: 1.2 $';
  39. $module_version =~ s!(\$\w+: | \$)!!g;
  40. $module_id    = '$Id: LogDebug.pm,v 1.2 1995/10/20 22:16:27 aswift Exp $';
  41. $module_id      =~ s!(\$\w+: | \$)!!g;
  42. $module_name    = $module_id;
  43. $module_name    =~ s!^([^\,]+).*$!$1!;
  44.  
  45. ############################################################################
  46. # Purpose: Module that encapsulates logging formatted debugging messages
  47. #
  48. # HISTORY: START
  49. # $Log: LogDebug.pm,v $
  50. # Revision 1.2  1995/10/20  22:16:27  aswift
  51. # Added DevMan style changes Log support
  52. #
  53. #
  54. # HISTORY: END
  55. ############################################################################
  56.  
  57. #############################################################################
  58. #
  59. # NAME:       module_version
  60. #
  61. # ACTION:     returns the version number of this module
  62. #
  63. # RETURN:     the module version
  64. #
  65. #############################################################################
  66. sub module_version
  67. {
  68.     return $module_version;
  69. }
  70.  
  71. sub module_versionstamp
  72. {
  73.     return "$module_name (rev-$module_version)";
  74. }
  75.  
  76. #############################################################################
  77. #
  78. # NAME:       set_dblog_debuglevel
  79. #
  80. # ACTION:     Sets a global variable which determines the threshold debugging
  81. #             level to produce output to stderr in dblog()
  82. #
  83. # GLOBALS:    The debugging level $LogDebug_debuglevel
  84. #
  85. # ARGUMENTS:  A log debugging level 
  86. #
  87. #############################################################################
  88. sub set_dblog_debuglevel
  89. {
  90.     $DebugLog_debuglevel = $_[0];
  91. }
  92.  
  93.  
  94.  
  95. #############################################################################
  96. #
  97. # NAME:       dblog_debuglevel
  98. #
  99. # ACTION:     Returns the value of the global variable which determines the 
  100. #             threshold debugging level to produce output to stderr in dblog()
  101. #
  102. # GLOBALS:    The debugging level $LogDebug_debuglevel
  103. #
  104. # RETURN:     The log debugging level
  105. #
  106. #############################################################################
  107. sub dblog_debuglevel
  108. {
  109.     return 0 if (!defined($DebugLog_debuglevel));
  110.     return $DebugLog_debuglevel;
  111. }
  112.  
  113.  
  114.  
  115. #############################################################################
  116. #
  117. # NAME:       dblog
  118. #
  119. # ACTION:     If the debugging level is set higher than the number in the 
  120. #             first argument then the remaining arguments are printed 
  121. #             to stderr
  122. #
  123. # GLOBALS:    The debugging level $LogDebug_debuglevel
  124. #
  125. # ARGUMENTS:  A log debugging level 
  126. #             A list of debugging messages
  127. #
  128. #############################################################################
  129. sub dblog
  130. {
  131.     local ($loglevel, $counter, $logstars);
  132.     
  133.     $loglevel = shift @_;
  134.  
  135.     $logstars = "";
  136.     if (&dblog_debuglevel() > $loglevel) {
  137.     if ($loglevel > 0) {
  138.         for ($counter = 6; $counter > $loglevel; $counter --) {
  139.         $logstars .= "*";
  140.         }
  141.     } else {
  142.         for ($counter = 0; $counter > $loglevel; $counter --) {
  143.         $logstars .= "=";
  144.         }
  145.         $logstars .= ">";
  146.     }
  147.     
  148.     print STDERR ("$logstars ", @_, "\n");
  149.     }
  150. }
  151.  
  152.  
  153.  
  154. 1;
  155.     
  156.