with Ada.Exceptions; use Ada.Exceptions;
with GNAT.Source_Info; use GNAT.Source_Info;
with Hashed_Strings; use Hashed_Strings;
package Debugging is
----------------------------------------------------------------------------
-- This package parses the command line arguments at elaboration time. The
-- following are the recognized arguments:
--
-- -DV=[verbosity] (Debugging Verbosity)
-- -DV[system]=[verbosity] (Debugging Verbosity per system)
--
-- Where:
-- [verbosity] is the verbosity level.
-- 'e' : Errors only
-- 'w' : Warnings and errors only
-- 'i' : All info, warnings and errors
--
-- [system] is the name of a specific debugging system. The standard
-- systems names are predefined in the Engine_Debuggin package.
--
-- -DD=[decoration] (Debugging Decoration)
--
-- [decoration] is the level of decoration for every line output by the
-- debugging package. The decoration levels are:
-- '0' : No decoration
-- '1' : Prefixed with current task image
-- '2' : Prefixed with calling source unit and current task image
----------------------------------------------------------------------------
type Output_Proc is access procedure( str : String );
-- Description of values:
-- SILENT : Never ever display output with this level.
-- ALWAYS : The default verbosity level, more verbose than SILENT but less
-- verbose than displaying only error messages. This is used for
-- temporary debugging output during source code development.
-- ERROR : Severe error messages and exceptions.
-- WARNING: Minor warning messages that can be ignored.
-- INFO : Informational messages that describe what is happening.
type Verbosity_Level is (SILENT, ALWAYS, ERROR, WARNING, INFO);
-- Description of values:
-- NONE : Display the text without decoration, as-is.
-- TASK_IMAGE : Prefix the text with the image of the current task.
-- SOURCE_UNIT : Include the calling source unit with the task image.
type Decoration_Level is (NONE, TASK_IMAGE, SOURCE_UNIT);
NO_SYSTEM : constant Hashed_String := To_Hashed_String( "" );
----------------------------------------------------------------------------
-- Sends a line of text to the debugging output procedure. Do not specify
-- entity and location; they are used to determine the calling location in
-- the code.
procedure Dbg( str : String;
system : Hashed_String := NO_SYSTEM;
level : Verbosity_Level := ALWAYS;
entity : String := GNAT.Source_Info.Enclosing_Entity;
location : String := GNAT.Source_Info.Source_Location );
-- Sends debugging information from an exception to the output procedure.
-- A stack traceback will also be displayed if available (Windows only.) Do
-- not specify entity and location; they are used to determine the calling
-- location in the code.
procedure Dbg( e : Exception_Occurrence;
system : Hashed_String := NO_SYSTEM;
level : Verbosity_Level := ALWAYS;
entity : String := GNAT.Source_Info.Enclosing_Entity;
location : String := GNAT.Source_Info.Source_Location );
-- Sets the global decoration level for output text.
procedure Set_Decoration( level : Decoration_Level );
-- Sets the procedure to receive debugging output. Passing a value of null
-- will disable all debugging output, which is effectively the same as
-- setting the global verbosity level to SILENT.
procedure Set_Output( output : Output_Proc );
-- Sets the global verbosity level. If an individual system has a higher
-- level of verbosity set then it will be respected. The default global
-- verbosity is WARNING for debug build and ALWAYS for a non-debug build.
procedure Set_Verbosity( level : Verbosity_Level );
-- Sets the maximum verbosity level per system. No output from 'system' with
-- a verbosity level higher than this will be displayed unless it is still
-- less than the global verbosity level.
procedure Set_Verbosity( system : Hashed_String; level : Verbosity_Level );
end Debugging;