agpl_1.0.0_b5da3320/src/agpl-trace-file.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
with Agpl.Calendar.Format;
with Agpl.Command_Line;
with Agpl.Trace.Root;

private with Ada.Finalization;
with Ada.Text_Io;

package Agpl.Trace.File is

   pragma Elaborate_Body;

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

   type Modes is (Append, Reset);

   overriding
   procedure Log (This    : in out Object;
                  Text    : in String;
                  Level   : in Levels;
                  Section : in String := "");

   not overriding
   procedure Set_File
     (This : in out Object;
      Name : in     String := Command_Line.Program_Name & "." &
                              Calendar.Format.Datestamp (Separator =>'.') &"."&
                              Calendar.Format.Timestamp & ".log";
      Mode : in     Modes  := Append);

private

   type Destructor_Type (Parent : access Object) is new
     Ada.Finalization.Limited_Controlled with null record;

   type Object is new Root.Object with record
      File       : Ada.Text_Io.File_Type;
      Opened     : Boolean := False;

      Destructor : Destructor_Type (Object'Access);
   end record;

   procedure Finalize (This : in out Destructor_Type);

end Agpl.Trace.File;