package Ada_Store.Support.Trace

package Ada_Store.Support.Trace is 
   pragma Elaborate_Body(Ada_Store.Support.Trace);
   
   procedure Put(Trace_This : in String);
end Ada_Store.Support.Trace;

with Ada;
use  Ada;
with Ada.Text_IO;
with Ada.IO_Exceptions;
with Ada.Calendar;
with Ada.Task_Identification;

package body Ada_Store.Support.Trace is 

   package Tasks renames Ada.Task_Identification;

   Trace_File      : Text_IO.File_Type;
   Trace_File_Name : constant String := "ada_store.trc";

   procedure Put
     (Trace_This : in String) is

      Seconds : Calendar.Day_Duration;
   begin
      Seconds := Calendar.Seconds(Calendar.Clock);

      Text_IO.Put_Line(Trace_File,
		       "**** Task " & 
		       Tasks.Image(Tasks.Current_Task) &
		       " At " &
		       Calendar.Day_Duration'Image(Seconds) &
                       " Wrote:");

      Text_IO.Put_Line(Trace_File,
		       Trace_This);

      Text_IO.Flush(Trace_File);
   end Put;

begin
   Text_IO.Open(Trace_File,
		Text_IO.Out_File,
		Trace_File_Name);
exception
   when Ada.IO_Exceptions.Name_Error =>
      Text_IO.Create(Trace_File,
		     Text_IO.Out_File,
		     Trace_File_Name);
end Ada_Store.Support.Trace;

Contents Page

Copyright © 1996 Simon Johnston &
Addison Wesley Longman