1. -- 
  2. --  Copyright (c) 2008-2009, 
  3. --  Reto Buerki, Adrian-Ken Rueegsegger 
  4. --  secunet SwissIT AG 
  5. -- 
  6. --  This file is part of Alog. 
  7. -- 
  8. --  Alog is free software; you can redistribute it and/or modify 
  9. --  it under the terms of the GNU Lesser General Public License as published 
  10. --  by the Free Software Foundation; either version 2.1 of the License, or 
  11. --  (at your option) any later version. 
  12. -- 
  13. --  Alog is distributed in the hope that it will be useful, 
  14. --  but WITHOUT ANY WARRANTY; without even the implied warranty of 
  15. --  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
  16. --  GNU Lesser General Public License for more details. 
  17. -- 
  18. --  You should have received a copy of the GNU Lesser General Public License 
  19. --  along with Alog; if not, write to the Free Software 
  20. --  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, 
  21. --  MA  02110-1301  USA 
  22. -- 
  23.  
  24. with Ada.Text_IO; 
  25.  
  26. --  File_Descriptor facility. Used to log to a console or file. If no file is 
  27. --  specified by a Set_Logfile()-call, console logging is used. 
  28. package Alog.Facilities.File_Descriptor is 
  29.  
  30.    type Instance is new Alog.Facilities.Instance with private; 
  31.    --  File Descriptor based logging facility. 
  32.  
  33.    type Handle is access all Instance; 
  34.  
  35.    overriding 
  36.    procedure Teardown (Facility : in out Instance); 
  37.    --  Implementation of Teardown-procedure. 
  38.  
  39.    procedure Set_Logfile 
  40.      (Facility : in out Instance; 
  41.       Path     :        String; 
  42.       Append   :        Boolean := True); 
  43.    --  Set logfile to use. If not set, standard output is used for logging. 
  44.    --  Set Append to False if an existing logfile should be overwritten. 
  45.  
  46.    function Get_Logfile (Facility : Instance) return Ada.Text_IO.File_Access; 
  47.    --  Get currently used logfile. 
  48.  
  49.    procedure Close_Logfile 
  50.      (Facility : in out Instance; 
  51.       Remove   :        Boolean := False); 
  52.    --  Close opened logfile. 
  53.  
  54.    Open_File_Error : exception; 
  55.    --  This exception is raised if an error occurs while trying to open a 
  56.    --  logfile. 
  57.  
  58. private 
  59.  
  60.    overriding 
  61.    procedure Write 
  62.      (Facility : Instance; 
  63.       Level    : Log_Level := Info; 
  64.       Msg      : String); 
  65.    --  Implementation of the Write procedure for FD. 
  66.  
  67.    type Instance is new Alog.Facilities.Instance with record 
  68.       Log_File      : aliased Ada.Text_IO.File_Type; 
  69.       --  Logfile used for file based logging. 
  70.  
  71.       Log_File_Ptr  : Ada.Text_IO.File_Access := 
  72.         Ada.Text_IO.Standard_Output; 
  73.       --  Reference to actual log file. Default is Standard_Output. 
  74.  
  75.       Log_File_Name : BS_Path.Bounded_String := 
  76.         To_Bounded_String ("none"); 
  77.       --  File name of log file. 
  78.    end record; 
  79.  
  80. end Alog.Facilities.File_Descriptor;