1. with Ada.Exceptions;                    use Ada.Exceptions; 
  2. with GNAT.Source_Info;                  use GNAT.Source_Info; 
  3. with Hashed_Strings;                    use Hashed_Strings; 
  4.  
  5. package Debugging is 
  6.  
  7.     ---------------------------------------------------------------------------- 
  8.     -- This package parses the command line arguments at elaboration time. The 
  9.     -- following are the recognized arguments: 
  10.     -- 
  11.     -- -DV=[verbosity]          (Debugging Verbosity) 
  12.     -- -DV[system]=[verbosity]  (Debugging Verbosity per system) 
  13.     -- 
  14.     --     Where: 
  15.     --     [verbosity] is the verbosity level. 
  16.     --         'e' : Errors only 
  17.     --         'w' : Warnings and errors only 
  18.     --         'i' : All info, warnings and errors 
  19.     -- 
  20.     --     [system] is the name of a specific debugging system. The standard 
  21.     --         systems names are predefined in the Engine_Debuggin package. 
  22.     -- 
  23.     -- -DD=[decoration]         (Debugging Decoration) 
  24.     -- 
  25.     --     Where: 
  26.     --     [decoration] is the level of decoration for every line output by the 
  27.     --         debugging package. The decoration levels are: 
  28.     --         '0' : No decoration 
  29.     --         '1' : Prefixed with current task image 
  30.     --         '2' : Prefixed with calling source unit and current task image 
  31.     -- 
  32.     -- -DF=[filename] 
  33.     -- 
  34.     --     Where: 
  35.     --     [filename] is the file name or path to write debugging information. 
  36.     --         Debugging output will be appended to the file. If just a filename 
  37.     --         is given, the file will be written to the current working 
  38.     --         directory. This is usually the same directory as the executable. 
  39.     ---------------------------------------------------------------------------- 
  40.  
  41.     -- The form of the procedure where debugging output is directed. 
  42.     type Output_Proc is access procedure( str : String ); 
  43.  
  44.     -- Description of values: 
  45.     -- SILENT : Never ever display output with this level. 
  46.     -- ALWAYS : The default verbosity level, more verbose than SILENT but less 
  47.     --          verbose than displaying only error messages. This is used for 
  48.     --          temporary debugging output during source code development. 
  49.     -- ERROR  : Severe error messages and exceptions. 
  50.     -- WARNING: Minor warning messages that can be ignored. 
  51.     -- INFO   : Informational messages that describe what is happening. 
  52.     type Verbosity_Level is (SILENT, ALWAYS, ERROR, WARNING, INFO); 
  53.  
  54.     -- Description of values: 
  55.     -- NONE        : Display the text without decoration, as-is. 
  56.     -- TASK_IMAGE  : Prefix the text with the image of the current task. 
  57.     -- SOURCE_UNIT : Include the calling source unit with the task image. 
  58.     type Decoration_Level is (NONE, TASK_IMAGE, SOURCE_UNIT); 
  59.  
  60.     NO_SYSTEM : constant Hashed_String := To_Hashed_String( "" ); 
  61.  
  62.     ---------------------------------------------------------------------------- 
  63.  
  64.     -- Sends a line of text to the debugging output procedure. Do not specify 
  65.     -- entity and location; they are used to determine the calling location in 
  66.     -- the code. 
  67.     procedure Dbg( str      : String; 
  68.                    system   : Hashed_String := NO_SYSTEM; 
  69.                    level    : Verbosity_Level := ALWAYS; 
  70.                    entity   : String := GNAT.Source_Info.Enclosing_Entity; 
  71.                    location : String := GNAT.Source_Info.Source_Location ); 
  72.  
  73.     -- Sends debugging information from an exception to the output procedure. 
  74.     -- A stack traceback will also be displayed if available (Windows only.) Do 
  75.     -- not specify entity and location; they are used to determine the calling 
  76.     -- location in the code. 
  77.     procedure Dbg( e        : Exception_Occurrence; 
  78.                    system   : Hashed_String := NO_SYSTEM; 
  79.                    level    : Verbosity_Level := ALWAYS; 
  80.                    entity   : String := GNAT.Source_Info.Enclosing_Entity; 
  81.                    location : String := GNAT.Source_Info.Source_Location ); 
  82.  
  83.     -- Sets the global decoration level for output text. 
  84.     procedure Set_Decoration( level : Decoration_Level ); 
  85.  
  86.     -- Sets the path of the file to log debug output to. Output will be appended 
  87.     -- to the contents of the file, if it exists. Output will also be sent to 
  88.     -- the registered outout procedure. 
  89.     procedure Set_Log_File( path : String ); 
  90.  
  91.     -- Sets the procedure to receive debugging output. Passing null will disable 
  92.     -- all debugging output, which is effectively the same as setting the 
  93.     -- global verbosity level to SILENT. 
  94.     procedure Set_Output( output : Output_Proc ); 
  95.  
  96.     -- Sets the global verbosity level. If an individual system has a higher 
  97.     -- level of verbosity set then it will be respected. The default global 
  98.     -- verbosity is WARNING for debug build and ALWAYS for a non-debug build. 
  99.     procedure Set_Verbosity( level : Verbosity_Level ); 
  100.  
  101.     -- Sets the maximum verbosity level per system. No output from 'system' with 
  102.     -- a verbosity level higher than this will be displayed unless it is still 
  103.     -- less than the global verbosity level. 
  104.     procedure Set_Verbosity( system : Hashed_String; level : Verbosity_Level ); 
  105.  
  106. end Debugging;