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