1. -- 
  2. --  Copyright (c) 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 Alog.Maps; 
  24.  
  25. --  Logging policy database package. This DB stores logging policies. Policies 
  26. --  in the database are used inside the framework for logging decisions. 
  27. package Alog.Policy_DB is 
  28.  
  29.    Alog_Default_Level : constant Log_Level := Info; 
  30.    --  Framework default loglevel. 
  31.  
  32.    procedure Set_Default_Loglevel (Level : Log_Level); 
  33.    --  Set given loglevel as default loglevel. 
  34.  
  35.    function Get_Default_Loglevel return Log_Level; 
  36.    --  Return current default loglevel. 
  37.  
  38.    procedure Set_Loglevel 
  39.      (Identifier : String; 
  40.       Level      : Log_Level); 
  41.    --  Set given loglevel for specified identifier string. If the identifier is 
  42.    --  already present the loglevel is updated. Identifier strings are 
  43.    --  case-sensitive. 
  44.    -- 
  45.    --  Use wildcards to specify a loglevel for a range of identifiers. 
  46.    --  Identifier hierarchies are separated by dots, the wildcard is '*'. The 
  47.    --  following example sets a Debug loglevel for all log-identifiers in 
  48.    --  Foo.Bar (including Foo.Bar). 
  49.    -- 
  50.    --  Example: 
  51.    --     Foo.Bar.* = Debug 
  52.    -- 
  53.    --  Direct matches take precedence over wildcard matches. In the following 
  54.    --  example the loglevel for identifier 'Foo.Bar' is explicitly set to Info. 
  55.    -- 
  56.    --  Example: 
  57.    --     Foo.Bar   = Info 
  58.    --     Foo.Bar.* = Debug 
  59.  
  60.    procedure Set_Loglevel (Identifiers : Maps.Wildcard_Level_Map); 
  61.    --  Apply loglevels for identifiers stored in map. 
  62.  
  63.    function Get_Loglevel (Identifier : String) return Log_Level; 
  64.    --  Return loglevel for given identifier string. Raises No_Ident_Loglevel 
  65.    --  exception if no entry for given identifier is found (exact match only, 
  66.    --  no wildcard lookup). 
  67.  
  68.    function Lookup (Identifier : String) return Log_Level; 
  69.    --  Return loglevel for given identifier string. Returns the closest match, 
  70.    --  if no associated loglevel is found the default loglevel is returned. 
  71.  
  72.    procedure Reset; 
  73.    --  Reset the logging policy database to the initial state. 
  74.  
  75.    function Accept_Src 
  76.      (Identifier : String := ""; 
  77.       Level      : Log_Level) 
  78.       return Boolean; 
  79.    --  Returns True if the given loglevel is accepted for a source identifier. 
  80.    --  If no identifier is given, the loglevel is verified against the default 
  81.    --  loglevel. 
  82.  
  83.    function Accept_Dst 
  84.      (Identifier : String; 
  85.       Level      : Log_Level) 
  86.       return Boolean; 
  87.    --  Returns True if the given loglevel is accepted for a destination 
  88.    --  identifier. If no match for the given identifier is found True is 
  89.    --  returned. 
  90.  
  91.    No_Ident_Loglevel : exception; 
  92.    --  Will be raised if loglevel is not found for a requested identifier. 
  93.  
  94. end Alog.Policy_DB;