agpl_1.0.0_b5da3320/src/agpl-trace-root.ads

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
--  Just implements sections but still doesn't trace.
with Ada.Containers.Indefinite_Ordered_Maps;
with Agpl.Containers.String_Sets;

package Agpl.Trace.Root is

   pragma Preelaborate;

   Bypass_Section_Level : Levels := Warning;
   --  >= this is logged regardless of section

   type Object is limited new Trace.Object with private;
   type Object_Access is access all Object'Class;

   pragma Preelaborable_Initialization (Object);

   overriding
   procedure Log (This    : in out Object;
                  Text    : in     String;
                  Level   : in     Levels;
                  Section : in     String := "") is null;
   --  No need for implementations of this object to call Must_Log, it's called
   --  in the Agpl.Trace.Log subprogram.

   overriding
   function Must_Log (This    : in Object;
                      Level   : in Levels;
                      Section : in String) return Boolean;

   overriding
   procedure Enable_Section  (This    : in out Object;
                              Section : in     String;
                              Enabled : in     Boolean := True);

   overriding
   procedure Enable_Section (This    : in out Object;
                             Section : String;
                             Level   : All_Levels);

   overriding
   procedure Set_Active (This : in out Object; Active : in Boolean := True);

   overriding
   procedure Set_Level  (This : in out Object; Level : in All_Levels);

   overriding
   procedure Set_Decorator (This : in out Object; Decor : in Decorator);

   overriding
   function Decorate (This    : in Object;
                      Text    : in String;
                      Level   : in Levels;
                      Section : in String) return String;

private

   package Section_Level_Maps is new
     Ada.Containers.Indefinite_Ordered_Maps (String, All_Levels);

   type Object is limited new Trace.Object with record
      Active   : Boolean    := True;
      Level    : All_Levels := Informative;
      Sections : Containers.String_Sets.Set;
      Section_Levels : Section_Level_Maps.Map;
      Decor    : Decorator;
   end record;

end Agpl.Trace.Root;